1and1 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/1and1-1.0.gem +0 -0
- data/1and1.gemspec +20 -0
- data/Gemfile +4 -0
- data/LICENSE +201 -0
- data/README.md +499 -0
- data/docs/reference.md +2447 -0
- data/examples/dvd_examples.rb +15 -0
- data/examples/example_app.rb +100 -0
- data/examples/firewall_examples.rb +137 -0
- data/examples/image_examples.rb +48 -0
- data/examples/load_balancer_examples.rb +145 -0
- data/examples/log_examples.rb +15 -0
- data/examples/monitoring_center_examples.rb +15 -0
- data/examples/monitoring_policy_examples.rb +343 -0
- data/examples/private_network_examples.rb +86 -0
- data/examples/public_ip_examples.rb +42 -0
- data/examples/role_examples.rb +113 -0
- data/examples/server_appliance_examples.rb +15 -0
- data/examples/server_examples.rb +438 -0
- data/examples/shared_storage_examples.rb +108 -0
- data/examples/usage_examples.rb +6 -0
- data/examples/user_examples.rb +113 -0
- data/examples/vpn_examples.rb +56 -0
- data/lib/1and1/datacenter.rb +73 -0
- data/lib/1and1/dvd.rb +73 -0
- data/lib/1and1/firewall.rb +427 -0
- data/lib/1and1/image.rb +231 -0
- data/lib/1and1/load_balancer.rb +448 -0
- data/lib/1and1/log.rb +77 -0
- data/lib/1and1/monitoring_center.rb +84 -0
- data/lib/1and1/monitoring_policy.rb +598 -0
- data/lib/1and1/oneandone.rb +57 -0
- data/lib/1and1/ping.rb +41 -0
- data/lib/1and1/ping_auth.rb +41 -0
- data/lib/1and1/pricing.rb +41 -0
- data/lib/1and1/private_network.rb +333 -0
- data/lib/1and1/public_ip.rb +192 -0
- data/lib/1and1/role.rb +381 -0
- data/lib/1and1/server.rb +1208 -0
- data/lib/1and1/server_appliance.rb +73 -0
- data/lib/1and1/shared_storage.rb +379 -0
- data/lib/1and1/usage.rb +58 -0
- data/lib/1and1/user.rb +374 -0
- data/lib/1and1/vpn.rb +249 -0
- data/lib/oneandone.rb +27 -0
- data/sphinx/Makefile +192 -0
- data/sphinx/_build/doctrees/dvds.doctree +0 -0
- data/sphinx/_build/doctrees/environment.pickle +0 -0
- data/sphinx/_build/doctrees/firewalls.doctree +0 -0
- data/sphinx/_build/doctrees/images.doctree +0 -0
- data/sphinx/_build/doctrees/index.doctree +0 -0
- data/sphinx/_build/doctrees/load_balancers.doctree +0 -0
- data/sphinx/_build/doctrees/logs.doctree +0 -0
- data/sphinx/_build/doctrees/monitoring_center.doctree +0 -0
- data/sphinx/_build/doctrees/monitoring_policies.doctree +0 -0
- data/sphinx/_build/doctrees/private_networks.doctree +0 -0
- data/sphinx/_build/doctrees/public_ips.doctree +0 -0
- data/sphinx/_build/doctrees/server_appliances.doctree +0 -0
- data/sphinx/_build/doctrees/servers.doctree +0 -0
- data/sphinx/_build/doctrees/shared_storages.doctree +0 -0
- data/sphinx/_build/doctrees/usages.doctree +0 -0
- data/sphinx/_build/doctrees/users.doctree +0 -0
- data/sphinx/_build/html/.buildinfo +4 -0
- data/sphinx/_build/html/_sources/dvds.txt +42 -0
- data/sphinx/_build/html/_sources/firewalls.txt +189 -0
- data/sphinx/_build/html/_sources/images.txt +101 -0
- data/sphinx/_build/html/_sources/index.txt +499 -0
- data/sphinx/_build/html/_sources/load_balancers.txt +231 -0
- data/sphinx/_build/html/_sources/logs.txt +55 -0
- data/sphinx/_build/html/_sources/monitoring_center.txt +55 -0
- data/sphinx/_build/html/_sources/monitoring_policies.txt +288 -0
- data/sphinx/_build/html/_sources/private_networks.txt +146 -0
- data/sphinx/_build/html/_sources/public_ips.txt +78 -0
- data/sphinx/_build/html/_sources/server_appliances.txt +42 -0
- data/sphinx/_build/html/_sources/servers.txt +630 -0
- data/sphinx/_build/html/_sources/shared_storages.txt +160 -0
- data/sphinx/_build/html/_sources/usages.txt +45 -0
- data/sphinx/_build/html/_sources/users.txt +172 -0
- data/sphinx/_build/html/_static/ajax-loader.gif +0 -0
- data/sphinx/_build/html/_static/alabaster.css +585 -0
- data/sphinx/_build/html/_static/basic.css +599 -0
- data/sphinx/_build/html/_static/comment-bright.png +0 -0
- data/sphinx/_build/html/_static/comment-close.png +0 -0
- data/sphinx/_build/html/_static/comment.png +0 -0
- data/sphinx/_build/html/_static/doctools.js +263 -0
- data/sphinx/_build/html/_static/down-pressed.png +0 -0
- data/sphinx/_build/html/_static/down.png +0 -0
- data/sphinx/_build/html/_static/file.png +0 -0
- data/sphinx/_build/html/_static/jquery-1.11.1.js +10308 -0
- data/sphinx/_build/html/_static/jquery.js +4 -0
- data/sphinx/_build/html/_static/minus.png +0 -0
- data/sphinx/_build/html/_static/plus.png +0 -0
- data/sphinx/_build/html/_static/pygments.css +63 -0
- data/sphinx/_build/html/_static/searchtools.js +651 -0
- data/sphinx/_build/html/_static/underscore-1.3.1.js +999 -0
- data/sphinx/_build/html/_static/underscore.js +31 -0
- data/sphinx/_build/html/_static/up-pressed.png +0 -0
- data/sphinx/_build/html/_static/up.png +0 -0
- data/sphinx/_build/html/_static/websupport.js +808 -0
- data/sphinx/_build/html/dvds.html +151 -0
- data/sphinx/_build/html/firewalls.html +397 -0
- data/sphinx/_build/html/genindex.html +114 -0
- data/sphinx/_build/html/images.html +236 -0
- data/sphinx/_build/html/index.html +571 -0
- data/sphinx/_build/html/load_balancers.html +409 -0
- data/sphinx/_build/html/logs.html +160 -0
- data/sphinx/_build/html/monitoring_center.html +160 -0
- data/sphinx/_build/html/monitoring_policies.html +530 -0
- data/sphinx/_build/html/objects.inv +0 -0
- data/sphinx/_build/html/private_networks.html +316 -0
- data/sphinx/_build/html/public_ips.html +215 -0
- data/sphinx/_build/html/rb-modindex.html +106 -0
- data/sphinx/_build/html/search.html +99 -0
- data/sphinx/_build/html/searchindex.js +1 -0
- data/sphinx/_build/html/server_appliances.html +153 -0
- data/sphinx/_build/html/servers.html +994 -0
- data/sphinx/_build/html/shared_storages.html +349 -0
- data/sphinx/_build/html/usages.html +140 -0
- data/sphinx/_build/html/users.html +363 -0
- data/sphinx/conf.py +287 -0
- data/sphinx/dvds.rst +42 -0
- data/sphinx/firewalls.rst +189 -0
- data/sphinx/images.rst +101 -0
- data/sphinx/index.rst +499 -0
- data/sphinx/load_balancers.rst +231 -0
- data/sphinx/logs.rst +55 -0
- data/sphinx/make.bat +263 -0
- data/sphinx/monitoring_center.rst +55 -0
- data/sphinx/monitoring_policies.rst +288 -0
- data/sphinx/private_networks.rst +146 -0
- data/sphinx/public_ips.rst +78 -0
- data/sphinx/server_appliances.rst +42 -0
- data/sphinx/servers.rst +630 -0
- data/sphinx/shared_storages.rst +160 -0
- data/sphinx/usages.rst +45 -0
- data/sphinx/users.rst +172 -0
- data/test/mock-api/add-firewall.json +66 -0
- data/test/mock-api/add-hdd.json +49 -0
- data/test/mock-api/add-lb.json +71 -0
- data/test/mock-api/add-new-ip.json +18 -0
- data/test/mock-api/add-pn.json +66 -0
- data/test/mock-api/add-port-mp.json +81 -0
- data/test/mock-api/add-process-mp.json +20 -0
- data/test/mock-api/add-rule-fp.json +33 -0
- data/test/mock-api/add-rule-lb.json +40 -0
- data/test/mock-api/add-server-ip.json +66 -0
- data/test/mock-api/add-server-mp.json +66 -0
- data/test/mock-api/assign-ip-fp.json +32 -0
- data/test/mock-api/assign-server-lb.json +39 -0
- data/test/mock-api/attach-server-pn.json +14 -0
- data/test/mock-api/attach-server-storage.json +24 -0
- data/test/mock-api/change-api-key.json +15 -0
- data/test/mock-api/change-password.json +5 -0
- data/test/mock-api/change-server-status.json +70 -0
- data/test/mock-api/clone-server.json +29 -0
- data/test/mock-api/create-fp.json +26 -0
- data/test/mock-api/create-image.json +30 -0
- data/test/mock-api/create-lb.json +33 -0
- data/test/mock-api/create-mp.json +81 -0
- data/test/mock-api/create-pn.json +11 -0
- data/test/mock-api/create-public-ip.json +10 -0
- data/test/mock-api/create-server.json +34 -0
- data/test/mock-api/create-snapshot.json +74 -0
- data/test/mock-api/create-storage.json +13 -0
- data/test/mock-api/create-user.json +14 -0
- data/test/mock-api/delete-fp.json +26 -0
- data/test/mock-api/delete-image.json +26 -0
- data/test/mock-api/delete-ip.json +15 -0
- data/test/mock-api/delete-lb.json +33 -0
- data/test/mock-api/delete-mp.json +71 -0
- data/test/mock-api/delete-pn.json +11 -0
- data/test/mock-api/delete-public-ip.json +10 -0
- data/test/mock-api/delete-rule-fp.json +26 -0
- data/test/mock-api/delete-server.json +50 -0
- data/test/mock-api/delete-snapshot.json +74 -0
- data/test/mock-api/delete-storage.json +24 -0
- data/test/mock-api/delete-user.json +15 -0
- data/test/mock-api/detach-server-lb.json +33 -0
- data/test/mock-api/detach-server-mp.json +65 -0
- data/test/mock-api/detach-server-storage.json +19 -0
- data/test/mock-api/edit-image.json +26 -0
- data/test/mock-api/eject-dvd.json +66 -0
- data/test/mock-api/fixed-server-flavors.json +70 -0
- data/test/mock-api/get-appliance.json +16 -0
- data/test/mock-api/get-dvd.json +9 -0
- data/test/mock-api/get-firewall.json +26 -0
- data/test/mock-api/get-fixed-server.json +17 -0
- data/test/mock-api/get-fp-rule.json +7 -0
- data/test/mock-api/get-hardware.json +13 -0
- data/test/mock-api/get-hdd.json +5 -0
- data/test/mock-api/get-image.json +26 -0
- data/test/mock-api/get-lb-rule.json +7 -0
- data/test/mock-api/get-lb-server.json +5 -0
- data/test/mock-api/get-load-balancer.json +33 -0
- data/test/mock-api/get-log.json +23 -0
- data/test/mock-api/get-monitoring-center.json +161 -0
- data/test/mock-api/get-mp-port.json +7 -0
- data/test/mock-api/get-mp-process.json +6 -0
- data/test/mock-api/get-mp-server.json +4 -0
- data/test/mock-api/get-mp.json +65 -0
- data/test/mock-api/get-pn-server.json +4 -0
- data/test/mock-api/get-private-network.json +20 -0
- data/test/mock-api/get-public-ip.json +10 -0
- data/test/mock-api/get-server-dvd.json +4 -0
- data/test/mock-api/get-server-image.json +4 -0
- data/test/mock-api/get-server-ip-fp.json +4 -0
- data/test/mock-api/get-server-ip.json +8 -0
- data/test/mock-api/get-server-pn.json +16 -0
- data/test/mock-api/get-server-status.json +4 -0
- data/test/mock-api/get-server-storage.json +5 -0
- data/test/mock-api/get-server.json +44 -0
- data/test/mock-api/get-storage.json +19 -0
- data/test/mock-api/get-usage.json +161 -0
- data/test/mock-api/get-user-api-key.json +3 -0
- data/test/mock-api/get-user-api.json +7 -0
- data/test/mock-api/get-user.json +15 -0
- data/test/mock-api/list-appliances.json +66 -0
- data/test/mock-api/list-credentials.json +5 -0
- data/test/mock-api/list-dvds.json +128 -0
- data/test/mock-api/list-firewalls.json +54 -0
- data/test/mock-api/list-fp-rules.json +16 -0
- data/test/mock-api/list-hdds.json +7 -0
- data/test/mock-api/list-images.json +54 -0
- data/test/mock-api/list-lb-rules.json +16 -0
- data/test/mock-api/list-lb-servers.json +12 -0
- data/test/mock-api/list-load-balancers.json +68 -0
- data/test/mock-api/list-logs.json +49 -0
- data/test/mock-api/list-monitoring-center-usages.json +90 -0
- data/test/mock-api/list-mp-ports.json +16 -0
- data/test/mock-api/list-mp-processes.json +14 -0
- data/test/mock-api/list-mp-servers.json +10 -0
- data/test/mock-api/list-mps.json +152 -0
- data/test/mock-api/list-pn-servers.json +10 -0
- data/test/mock-api/list-private-networks.json +24 -0
- data/test/mock-api/list-public-ips.json +44 -0
- data/test/mock-api/list-server-fps.json +4 -0
- data/test/mock-api/list-server-ips-fp.json +7 -0
- data/test/mock-api/list-server-ips.json +10 -0
- data/test/mock-api/list-server-lbs.json +6 -0
- data/test/mock-api/list-server-pns.json +6 -0
- data/test/mock-api/list-servers.json +66 -0
- data/test/mock-api/list-snapshots.json +7 -0
- data/test/mock-api/list-storages.json +47 -0
- data/test/mock-api/list-usages.json +144 -0
- data/test/mock-api/list-user-ips.json +5 -0
- data/test/mock-api/list-users.json +31 -0
- data/test/mock-api/load-dvd.json +63 -0
- data/test/mock-api/modify-fp.json +26 -0
- data/test/mock-api/modify-lb.json +33 -0
- data/test/mock-api/modify-mp.json +81 -0
- data/test/mock-api/modify-pn.json +20 -0
- data/test/mock-api/modify-port-mp.json +81 -0
- data/test/mock-api/modify-process-mp.json +73 -0
- data/test/mock-api/modify-public-ip.json +10 -0
- data/test/mock-api/modify-server-hardware.json +44 -0
- data/test/mock-api/modify-server-hdd.json +54 -0
- data/test/mock-api/modify-server.json +44 -0
- data/test/mock-api/modify-storage.json +19 -0
- data/test/mock-api/modify-user-api.json +15 -0
- data/test/mock-api/modify-user.json +15 -0
- data/test/mock-api/reinstall-image.json +52 -0
- data/test/mock-api/remove-firewall-policy.json +26 -0
- data/test/mock-api/remove-hdd.json +54 -0
- data/test/mock-api/remove-ip-fp.json +26 -0
- data/test/mock-api/remove-lb.json +66 -0
- data/test/mock-api/remove-pn.json +71 -0
- data/test/mock-api/remove-port-mp.json +73 -0
- data/test/mock-api/remove-process-mp.json +66 -0
- data/test/mock-api/remove-rule-lb.json +33 -0
- data/test/mock-api/remove-server-ip.json +58 -0
- data/test/mock-api/remove-server-pn.json +16 -0
- data/test/mock-api/restore-snapshot.json +55 -0
- data/test/mock-api/storage-servers.json +12 -0
- data/test/test_mock_dvd.rb +55 -0
- data/test/test_mock_firewall.rb +309 -0
- data/test/test_mock_image.rb +123 -0
- data/test/test_mock_load_balancer.rb +312 -0
- data/test/test_mock_log.rb +55 -0
- data/test/test_mock_monitoring_center.rb +55 -0
- data/test/test_mock_monitoring_policy.rb +587 -0
- data/test/test_mock_private_network.rb +206 -0
- data/test/test_mock_public_ip.rb +118 -0
- data/test/test_mock_server.rb +929 -0
- data/test/test_mock_server_appliance.rb +55 -0
- data/test/test_mock_shared_storage.rb +256 -0
- data/test/test_mock_usage.rb +34 -0
- data/test/test_mock_user.rb +270 -0
- metadata +360 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative '../lib/oneandone'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class TestServerAppliance < Minitest::Test
|
5
|
+
def setup
|
6
|
+
|
7
|
+
OneAndOne.start('TEST-API-KEY')
|
8
|
+
@appliance = OneAndOne::ServerAppliance.new(test: true)
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def test_list
|
14
|
+
|
15
|
+
# Read in mock JSON
|
16
|
+
file = File.read('mock-api/list-appliances.json')
|
17
|
+
data = JSON.parse(file)
|
18
|
+
|
19
|
+
# Create stub and perform call
|
20
|
+
Excon.stub({:method => :get, :path => '/v1/server_appliances'},
|
21
|
+
{:body => JSON.generate(data), :status => 200})
|
22
|
+
|
23
|
+
response = @appliance.list
|
24
|
+
|
25
|
+
# Assertions
|
26
|
+
assert_equal response[0]['id'], data[0]['id']
|
27
|
+
|
28
|
+
# Clear out stubs
|
29
|
+
Excon.stubs.clear
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def test_get
|
35
|
+
|
36
|
+
# Read in mock JSON
|
37
|
+
file = File.read('mock-api/get-appliance.json')
|
38
|
+
data = JSON.parse(file)
|
39
|
+
|
40
|
+
# Create stub and perform call
|
41
|
+
Excon.stub({:method => :get, :path => "/v1/server_appliances/#{data['id']}"},
|
42
|
+
{:body => JSON.generate(data), :status => 200})
|
43
|
+
|
44
|
+
response = @appliance.get(appliance_id: data['id'])
|
45
|
+
|
46
|
+
# Assertions
|
47
|
+
assert_equal response['id'], data['id']
|
48
|
+
|
49
|
+
# Clear out stubs
|
50
|
+
Excon.stubs.clear
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,256 @@
|
|
1
|
+
require_relative '../lib/oneandone'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class TestSharedStorage < Minitest::Test
|
5
|
+
def setup
|
6
|
+
|
7
|
+
OneAndOne.start('TEST-API-KEY')
|
8
|
+
@shared_storage = OneAndOne::SharedStorage.new(test: true)
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def test_list
|
14
|
+
|
15
|
+
# Read in mock JSON
|
16
|
+
file = File.read('mock-api/list-storages.json')
|
17
|
+
data = JSON.parse(file)
|
18
|
+
|
19
|
+
# Create stub and perform call
|
20
|
+
Excon.stub({:method => :get, :path => '/v1/shared_storages'},
|
21
|
+
{:body => JSON.generate(data), :status => 200})
|
22
|
+
|
23
|
+
response = @shared_storage.list
|
24
|
+
|
25
|
+
# Assertions
|
26
|
+
assert_equal response[0]['id'], data[0]['id']
|
27
|
+
|
28
|
+
# Clear out stubs
|
29
|
+
Excon.stubs.clear
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def test_create
|
35
|
+
|
36
|
+
# Read in mock JSON
|
37
|
+
file = File.read('mock-api/create-storage.json')
|
38
|
+
data = JSON.parse(file)
|
39
|
+
|
40
|
+
# Create stub and perform call
|
41
|
+
Excon.stub({:method => :post, :path => '/v1/shared_storages'},
|
42
|
+
{:body => JSON.generate(data), :status => 202})
|
43
|
+
|
44
|
+
response = @shared_storage.create(name: data['name'],
|
45
|
+
description: data['description'], size: 200)
|
46
|
+
|
47
|
+
# Assertions
|
48
|
+
assert_equal response['size'], 200
|
49
|
+
|
50
|
+
# Clear out stubs
|
51
|
+
Excon.stubs.clear
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def test_get
|
57
|
+
|
58
|
+
# Read in mock JSON
|
59
|
+
file = File.read('mock-api/get-storage.json')
|
60
|
+
data = JSON.parse(file)
|
61
|
+
|
62
|
+
# Create stub and perform call
|
63
|
+
Excon.stub({:method => :get, :path => "/v1/shared_storages/#{data['id']}"},
|
64
|
+
{:body => JSON.generate(data), :status => 200})
|
65
|
+
|
66
|
+
response = @shared_storage.get(shared_storage_id: data['id'])
|
67
|
+
|
68
|
+
# Assertions
|
69
|
+
assert_equal response['id'], data['id']
|
70
|
+
|
71
|
+
# Clear out stubs
|
72
|
+
Excon.stubs.clear
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
def test_modify
|
78
|
+
|
79
|
+
# Read in mock JSON
|
80
|
+
file = File.read('mock-api/modify-storage.json')
|
81
|
+
data = JSON.parse(file)
|
82
|
+
|
83
|
+
# Create stub and perform call
|
84
|
+
Excon.stub({:method => :put, :path => "/v1/shared_storages/#{data['id']}"},
|
85
|
+
{:body => JSON.generate(data), :status => 202})
|
86
|
+
|
87
|
+
response = @shared_storage.modify(shared_storage_id: data['id'],
|
88
|
+
name: data['name'], size: 250)
|
89
|
+
|
90
|
+
# Assertions
|
91
|
+
assert_equal response['name'], 'My shared storage test rename'
|
92
|
+
|
93
|
+
# Clear out stubs
|
94
|
+
Excon.stubs.clear
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def test_delete
|
100
|
+
|
101
|
+
# Read in mock JSON
|
102
|
+
file = File.read('mock-api/delete-storage.json')
|
103
|
+
data = JSON.parse(file)
|
104
|
+
|
105
|
+
# Create stub and perform call
|
106
|
+
Excon.stub({:method => :delete, :path => "/v1/shared_storages/#{data['id']}"},
|
107
|
+
{:body => JSON.generate(data), :status => 202})
|
108
|
+
|
109
|
+
response = @shared_storage.delete(shared_storage_id: data['id'])
|
110
|
+
|
111
|
+
# Assertions
|
112
|
+
assert_equal response['state'], 'REMOVING'
|
113
|
+
|
114
|
+
# Clear out stubs
|
115
|
+
Excon.stubs.clear
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
def test_add_servers
|
121
|
+
|
122
|
+
# Read in mock JSON
|
123
|
+
file = File.read('mock-api/attach-server-storage.json')
|
124
|
+
data = JSON.parse(file)
|
125
|
+
|
126
|
+
# Create stub and perform call
|
127
|
+
Excon.stub({:method => :post, :path => "/v1/shared_storages/#{data['id']}/servers"},
|
128
|
+
{:body => JSON.generate(data), :status => 202})
|
129
|
+
|
130
|
+
server1 = {
|
131
|
+
'id' => '<SERVER-ID>',
|
132
|
+
'rights' => 'RW'
|
133
|
+
}
|
134
|
+
|
135
|
+
servers = [server1]
|
136
|
+
|
137
|
+
response = @shared_storage.add_servers(shared_storage_id: data['id'],
|
138
|
+
servers: servers)
|
139
|
+
|
140
|
+
# Assertions
|
141
|
+
assert_equal response['servers'][0]['id'], '638ED28205B1AFD7ADEF569C725DD85F'
|
142
|
+
|
143
|
+
# Clear out stubs
|
144
|
+
Excon.stubs.clear
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
def test_servers
|
150
|
+
|
151
|
+
# Read in mock JSON
|
152
|
+
file = File.read('mock-api/storage-servers.json')
|
153
|
+
data = JSON.parse(file)
|
154
|
+
|
155
|
+
# Create stub and perform call
|
156
|
+
Excon.stub({:method => :get, :path => "/v1/shared_storages/SHARED-STORAGE-ID/servers"},
|
157
|
+
{:body => JSON.generate(data), :status => 200})
|
158
|
+
|
159
|
+
response = @shared_storage.servers(shared_storage_id: 'SHARED-STORAGE-ID')
|
160
|
+
|
161
|
+
# Assertions
|
162
|
+
assert_equal response[0]['id'], data[0]['id']
|
163
|
+
|
164
|
+
# Clear out stubs
|
165
|
+
Excon.stubs.clear
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
def test_server
|
171
|
+
|
172
|
+
# Read in mock JSON
|
173
|
+
file = File.read('mock-api/get-server-storage.json')
|
174
|
+
data = JSON.parse(file)
|
175
|
+
|
176
|
+
# Create stub and perform call
|
177
|
+
Excon.stub({:method => :get, :path => "/v1/shared_storages/SHARED-STORAGE-ID/servers/#{data['id']}"},
|
178
|
+
{:body => JSON.generate(data), :status => 200})
|
179
|
+
|
180
|
+
response = @shared_storage.server(shared_storage_id: 'SHARED-STORAGE-ID',
|
181
|
+
server_id: data['id'])
|
182
|
+
|
183
|
+
# Assertions
|
184
|
+
assert_equal response['id'], data['id']
|
185
|
+
|
186
|
+
# Clear out stubs
|
187
|
+
Excon.stubs.clear
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
def test_remove_server
|
193
|
+
|
194
|
+
# Read in mock JSON
|
195
|
+
file = File.read('mock-api/detach-server-storage.json')
|
196
|
+
data = JSON.parse(file)
|
197
|
+
|
198
|
+
# Create stub and perform call
|
199
|
+
Excon.stub({:method => :delete, :path => "/v1/shared_storages/#{data['id']}/servers/#{data['servers'][0]['id']}"},
|
200
|
+
{:body => JSON.generate(data), :status => 202})
|
201
|
+
|
202
|
+
response = @shared_storage.remove_server(shared_storage_id: data['id'],
|
203
|
+
server_id: data['servers'][0]['id'])
|
204
|
+
|
205
|
+
# Assertions
|
206
|
+
assert_equal response['servers'].length, 1
|
207
|
+
|
208
|
+
# Clear out stubs
|
209
|
+
Excon.stubs.clear
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
def test_access
|
215
|
+
|
216
|
+
# Read in mock JSON
|
217
|
+
file = File.read('mock-api/list-credentials.json')
|
218
|
+
data = JSON.parse(file)
|
219
|
+
|
220
|
+
# Create stub and perform call
|
221
|
+
Excon.stub({:method => :get, :path => "/v1/shared_storages/access"},
|
222
|
+
{:body => JSON.generate(data), :status => 200})
|
223
|
+
|
224
|
+
response = @shared_storage.access
|
225
|
+
|
226
|
+
# Assertions
|
227
|
+
assert_equal response['user_domain'], data['user_domain']
|
228
|
+
|
229
|
+
# Clear out stubs
|
230
|
+
Excon.stubs.clear
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
|
235
|
+
def test_change_password
|
236
|
+
|
237
|
+
# Read in mock JSON
|
238
|
+
file = File.read('mock-api/change-password.json')
|
239
|
+
data = JSON.parse(file)
|
240
|
+
|
241
|
+
# Create stub and perform call
|
242
|
+
Excon.stub({:method => :put, :path => "/v1/shared_storages/access"},
|
243
|
+
{:body => JSON.generate(data), :status => 202})
|
244
|
+
|
245
|
+
response = @shared_storage.change_password(password: 'asdasdfgagsw32')
|
246
|
+
|
247
|
+
# Assertions
|
248
|
+
assert_equal response['state'], 'CONFIGURING'
|
249
|
+
|
250
|
+
# Clear out stubs
|
251
|
+
Excon.stubs.clear
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../lib/oneandone'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class TestUsage < Minitest::Test
|
5
|
+
def setup
|
6
|
+
|
7
|
+
OneAndOne.start('TEST-API-KEY')
|
8
|
+
@usage = OneAndOne::Usage.new(test: true)
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def test_list
|
14
|
+
|
15
|
+
# Read in mock JSON
|
16
|
+
file = File.read('mock-api/list-usages.json')
|
17
|
+
data = JSON.parse(file)
|
18
|
+
|
19
|
+
# Create stub and perform call
|
20
|
+
Excon.stub({:method => :get, :path => '/v1/usages'},
|
21
|
+
{:body => JSON.generate(data), :status => 200})
|
22
|
+
|
23
|
+
response = @usage.list
|
24
|
+
|
25
|
+
# Assertions
|
26
|
+
assert_equal response['SERVERS'][0]['id'], data['SERVERS'][0]['id']
|
27
|
+
|
28
|
+
# Clear out stubs
|
29
|
+
Excon.stubs.clear
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,270 @@
|
|
1
|
+
require_relative '../lib/oneandone'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class TestUser < Minitest::Test
|
5
|
+
def setup
|
6
|
+
|
7
|
+
OneAndOne.start('TEST-API-KEY')
|
8
|
+
@user = OneAndOne::User.new(test: true)
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def test_list
|
14
|
+
|
15
|
+
# Read in mock JSON
|
16
|
+
file = File.read('mock-api/list-users.json')
|
17
|
+
data = JSON.parse(file)
|
18
|
+
|
19
|
+
# Create stub and perform call
|
20
|
+
Excon.stub({:method => :get, :path => '/v1/users'},
|
21
|
+
{:body => JSON.generate(data), :status => 200})
|
22
|
+
|
23
|
+
response = @user.list
|
24
|
+
|
25
|
+
# Assertions
|
26
|
+
assert_equal response[0]['id'], data[0]['id']
|
27
|
+
|
28
|
+
# Clear out stubs
|
29
|
+
Excon.stubs.clear
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def test_create
|
35
|
+
|
36
|
+
# Read in mock JSON
|
37
|
+
file = File.read('mock-api/create-user.json')
|
38
|
+
data = JSON.parse(file)
|
39
|
+
|
40
|
+
# Create stub and perform call
|
41
|
+
Excon.stub({:method => :post, :path => '/v1/users'},
|
42
|
+
{:body => JSON.generate(data), :status => 202})
|
43
|
+
|
44
|
+
response = @user.create(name: 'Test', email: 'test@example.com',
|
45
|
+
password: 'testpass')
|
46
|
+
|
47
|
+
# Assertions
|
48
|
+
assert_equal response['id'], data['id']
|
49
|
+
|
50
|
+
# Clear out stubs
|
51
|
+
Excon.stubs.clear
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def test_get
|
57
|
+
|
58
|
+
# Read in mock JSON
|
59
|
+
file = File.read('mock-api/get-user.json')
|
60
|
+
data = JSON.parse(file)
|
61
|
+
|
62
|
+
# Create stub and perform call
|
63
|
+
Excon.stub({:method => :get, :path => "/v1/users/#{data['id']}"},
|
64
|
+
{:body => JSON.generate(data), :status => 200})
|
65
|
+
|
66
|
+
response = @user.get(user_id: data['id'])
|
67
|
+
|
68
|
+
# Assertions
|
69
|
+
assert_equal response['id'], data['id']
|
70
|
+
|
71
|
+
# Clear out stubs
|
72
|
+
Excon.stubs.clear
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
def test_modify
|
78
|
+
|
79
|
+
# Read in mock JSON
|
80
|
+
file = File.read('mock-api/modify-user.json')
|
81
|
+
data = JSON.parse(file)
|
82
|
+
|
83
|
+
# Create stub and perform call
|
84
|
+
Excon.stub({:method => :put, :path => "/v1/users/#{data['id']}"},
|
85
|
+
{:body => JSON.generate(data), :status => 202})
|
86
|
+
|
87
|
+
response = @user.modify(user_id: data['id'], description: 'New Desc')
|
88
|
+
|
89
|
+
# Assertions
|
90
|
+
assert_equal response['id'], data['id']
|
91
|
+
|
92
|
+
# Clear out stubs
|
93
|
+
Excon.stubs.clear
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def test_delete
|
99
|
+
|
100
|
+
# Read in mock JSON
|
101
|
+
file = File.read('mock-api/delete-user.json')
|
102
|
+
data = JSON.parse(file)
|
103
|
+
|
104
|
+
# Create stub and perform call
|
105
|
+
Excon.stub({:method => :delete, :path => "/v1/users/#{data['id']}"},
|
106
|
+
{:body => JSON.generate(data), :status => 202})
|
107
|
+
|
108
|
+
response = @user.delete(user_id: data['id'])
|
109
|
+
|
110
|
+
# Assertions
|
111
|
+
assert_equal response['state'], 'REMOVING'
|
112
|
+
|
113
|
+
# Clear out stubs
|
114
|
+
Excon.stubs.clear
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
def test_api
|
120
|
+
|
121
|
+
# Read in mock JSON
|
122
|
+
file = File.read('mock-api/get-user-api.json')
|
123
|
+
data = JSON.parse(file)
|
124
|
+
|
125
|
+
# Create stub and perform call
|
126
|
+
Excon.stub({:method => :get, :path => "/v1/users/USER-ID/api"},
|
127
|
+
{:body => JSON.generate(data), :status => 200})
|
128
|
+
|
129
|
+
response = @user.api(user_id: 'USER-ID')
|
130
|
+
|
131
|
+
# Assertions
|
132
|
+
assert_equal response['key'], data['key']
|
133
|
+
|
134
|
+
# Clear out stubs
|
135
|
+
Excon.stubs.clear
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
def test_enable_api
|
141
|
+
|
142
|
+
# Read in mock JSON
|
143
|
+
file = File.read('mock-api/modify-user-api.json')
|
144
|
+
data = JSON.parse(file)
|
145
|
+
|
146
|
+
# Create stub and perform call
|
147
|
+
Excon.stub({:method => :put, :path => "/v1/users/#{data['id']}/api"},
|
148
|
+
{:body => JSON.generate(data), :status => 202})
|
149
|
+
|
150
|
+
response = @user.enable_api(user_id: data['id'], active: true)
|
151
|
+
|
152
|
+
# Assertions
|
153
|
+
assert_equal response['api']['active'], true
|
154
|
+
|
155
|
+
# Clear out stubs
|
156
|
+
Excon.stubs.clear
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
def test_api_key
|
162
|
+
|
163
|
+
# Read in mock JSON
|
164
|
+
file = File.read('mock-api/get-user-api-key.json')
|
165
|
+
data = JSON.parse(file)
|
166
|
+
|
167
|
+
# Create stub and perform call
|
168
|
+
Excon.stub({:method => :get, :path => "/v1/users/USER-ID/api/key"},
|
169
|
+
{:body => JSON.generate(data), :status => 200})
|
170
|
+
|
171
|
+
response = @user.api_key(user_id: 'USER-ID')
|
172
|
+
|
173
|
+
# Assertions
|
174
|
+
assert_equal response['key'], data['key']
|
175
|
+
|
176
|
+
# Clear out stubs
|
177
|
+
Excon.stubs.clear
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
def test_change_key
|
183
|
+
|
184
|
+
# Read in mock JSON
|
185
|
+
file = File.read('mock-api/change-api-key.json')
|
186
|
+
data = JSON.parse(file)
|
187
|
+
|
188
|
+
# Create stub and perform call
|
189
|
+
Excon.stub({:method => :put, :path => "/v1/users/#{data['id']}/api/key"},
|
190
|
+
{:body => JSON.generate(data), :status => 202})
|
191
|
+
|
192
|
+
response = @user.change_key(user_id: data['id'])
|
193
|
+
|
194
|
+
# Assertions
|
195
|
+
assert_equal response['state'], 'CONFIGURING'
|
196
|
+
|
197
|
+
# Clear out stubs
|
198
|
+
Excon.stubs.clear
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
def test_ips
|
204
|
+
|
205
|
+
# Read in mock JSON
|
206
|
+
file = File.read('mock-api/list-user-ips.json')
|
207
|
+
data = JSON.parse(file)
|
208
|
+
|
209
|
+
# Create stub and perform call
|
210
|
+
Excon.stub({:method => :get, :path => "/v1/users/USER-ID/api/ips"},
|
211
|
+
{:body => JSON.generate(data), :status => 200})
|
212
|
+
|
213
|
+
response = @user.ips(user_id: 'USER-ID')
|
214
|
+
|
215
|
+
# Assertions
|
216
|
+
assert_equal response[0], '214.4.143.138'
|
217
|
+
|
218
|
+
# Clear out stubs
|
219
|
+
Excon.stubs.clear
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
|
224
|
+
def test_add_ips
|
225
|
+
|
226
|
+
# Read in mock JSON
|
227
|
+
file = File.read('mock-api/add-new-ip.json')
|
228
|
+
data = JSON.parse(file)
|
229
|
+
|
230
|
+
# Create stub and perform call
|
231
|
+
Excon.stub({:method => :post, :path => "/v1/users/#{data['id']}/api/ips"},
|
232
|
+
{:body => JSON.generate(data), :status => 202})
|
233
|
+
|
234
|
+
ip1 = '1.2.3.4'
|
235
|
+
|
236
|
+
ips = [ip1]
|
237
|
+
|
238
|
+
response = @user.add_ips(user_id: data['id'], ips: ips)
|
239
|
+
|
240
|
+
# Assertions
|
241
|
+
assert_equal response['api']['allowed_ips'][0], '214.4.143.138'
|
242
|
+
|
243
|
+
# Clear out stubs
|
244
|
+
Excon.stubs.clear
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
|
249
|
+
def test_remove_ip
|
250
|
+
|
251
|
+
# Read in mock JSON
|
252
|
+
file = File.read('mock-api/delete-ip.json')
|
253
|
+
data = JSON.parse(file)
|
254
|
+
|
255
|
+
# Create stub and perform call
|
256
|
+
Excon.stub({:method => :delete, :path => "/v1/users/#{data['id']}/api/ips/IP"},
|
257
|
+
{:body => JSON.generate(data), :status => 202})
|
258
|
+
|
259
|
+
response = @user.remove_ip(user_id: data['id'], ip: 'IP')
|
260
|
+
|
261
|
+
# Assertions
|
262
|
+
assert_equal response['api']['allowed_ips'], []
|
263
|
+
|
264
|
+
# Clear out stubs
|
265
|
+
Excon.stubs.clear
|
266
|
+
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
end
|