misty 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -23
- data/lib/misty/auth.rb +24 -19
- data/lib/misty/auth/auth_v2.rb +12 -12
- data/lib/misty/auth/auth_v3.rb +15 -15
- data/lib/misty/autoload.rb +27 -27
- data/lib/misty/cloud.rb +2 -1
- data/lib/misty/http/client.rb +17 -15
- data/lib/misty/http/method_builder.rb +1 -1
- data/lib/misty/http/net_http.rb +12 -7
- data/lib/misty/http/request.rb +13 -7
- data/lib/misty/misty.rb +30 -30
- data/lib/misty/openstack/aodh/v2.rb +1 -1
- data/lib/misty/openstack/ceilometer/v2.rb +1 -1
- data/lib/misty/openstack/cinder/v1.rb +2 -2
- data/lib/misty/openstack/cinder/v2.rb +2 -2
- data/lib/misty/openstack/cinder/v3.rb +2 -2
- data/lib/misty/openstack/designate/v2.rb +1 -1
- data/lib/misty/openstack/freezer/v1.rb +1 -1
- data/lib/misty/openstack/glance/v1.rb +1 -1
- data/lib/misty/openstack/glance/v2.rb +1 -1
- data/lib/misty/openstack/heat/v1.rb +2 -2
- data/lib/misty/openstack/ironic/v1.rb +2 -2
- data/lib/misty/openstack/karbor/v1.rb +1 -1
- data/lib/misty/openstack/keystone/v2_0.rb +2 -2
- data/lib/misty/openstack/keystone/v3.rb +2 -2
- data/lib/misty/openstack/magnum/v1.rb +2 -2
- data/lib/misty/openstack/manila/v2.rb +2 -2
- data/lib/misty/openstack/microversion.rb +9 -9
- data/lib/misty/openstack/murano/v1.rb +1 -1
- data/lib/misty/openstack/neutron/v2_0.rb +1 -1
- data/lib/misty/openstack/nova/v2_1.rb +4 -4
- data/lib/misty/openstack/octavia/v2_0.rb +1 -1
- data/lib/misty/openstack/sahara/v1_1.rb +1 -1
- data/lib/misty/openstack/searchlight/v1.rb +1 -1
- data/lib/misty/openstack/senlin/v1.rb +1 -1
- data/lib/misty/openstack/swift/v1.rb +1 -1
- data/lib/misty/openstack/tacker/v1_0.rb +1 -1
- data/lib/misty/openstack/trove/v1_0.rb +1 -1
- data/lib/misty/openstack/zaqar/v2.rb +1 -1
- data/lib/misty/services.rb +1 -1
- data/lib/misty/version.rb +1 -1
- data/test/integration/compute_test.rb +17 -17
- data/test/integration/network_test.rb +16 -16
- data/test/integration/orchestration_test.rb +51 -51
- data/test/integration/test_helper.rb +7 -7
- data/test/unit/auth/name_test.rb +53 -53
- data/test/unit/auth_test.rb +151 -152
- data/test/unit/cloud/requests_test.rb +58 -58
- data/test/unit/cloud/services_test.rb +62 -62
- data/test/unit/cloud_test.rb +48 -48
- data/test/unit/http/client_test.rb +21 -28
- data/test/unit/http/direct_test.rb +31 -31
- data/test/unit/http/method_builder_test.rb +42 -42
- data/test/unit/http/request_test.rb +33 -33
- data/test/unit/misty_test.rb +28 -28
- data/test/unit/openstack/APIs_test.rb +3 -3
- data/test/unit/openstack/microversion_test.rb +14 -14
- data/test/unit/service_helper.rb +4 -4
- data/test/unit/services_test.rb +5 -5
- data/test/unit/test_helper.rb +1 -1
- metadata +4 -4
data/test/unit/auth_test.rb
CHANGED
@@ -2,300 +2,299 @@ require 'test_helper'
|
|
2
2
|
require 'auth_helper'
|
3
3
|
|
4
4
|
describe Misty::Auth do
|
5
|
-
let(:
|
6
|
-
|
7
|
-
Net::HTTP.new(endpoint.host, endpoint.port)
|
5
|
+
let(:config) do
|
6
|
+
Misty::Cloud::Config.new
|
8
7
|
end
|
9
8
|
|
10
9
|
describe Misty::AuthV3 do
|
11
|
-
describe
|
12
|
-
it
|
13
|
-
stub_request(:post,
|
14
|
-
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {
|
10
|
+
describe '#new' do
|
11
|
+
it 'fails when missing credentials' do
|
12
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
13
|
+
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {'x-subject-token'=>'token_data'})
|
15
14
|
|
16
15
|
proc do
|
17
|
-
Misty::AuthV3.new({},
|
18
|
-
end.must_raise Misty::Auth::
|
16
|
+
Misty::AuthV3.new({}, config)
|
17
|
+
end.must_raise Misty::Auth::URLError
|
19
18
|
end
|
20
19
|
|
21
|
-
describe
|
22
|
-
describe
|
23
|
-
it
|
20
|
+
describe 'using the password method' do
|
21
|
+
describe 'with a project scope' do
|
22
|
+
it 'authenticates using a project id' do
|
24
23
|
auth = {
|
25
|
-
:url =>
|
26
|
-
:user_id =>
|
27
|
-
:password =>
|
28
|
-
:project_id =>
|
24
|
+
:url => 'http://localhost:5000',
|
25
|
+
:user_id => 'user_id',
|
26
|
+
:password => 'secret',
|
27
|
+
:project_id => 'project_id'
|
29
28
|
}
|
30
29
|
|
31
|
-
stub_request(:post,
|
30
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
32
31
|
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"project\":{\"id\":\"project_id\"}}}}").
|
33
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
32
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
34
33
|
|
35
|
-
Misty::AuthV3.new(auth,
|
34
|
+
Misty::AuthV3.new(auth, config)
|
36
35
|
end
|
37
36
|
|
38
|
-
it
|
37
|
+
it 'authenticates using a project name and a project domain id' do
|
39
38
|
auth = {
|
40
|
-
:url =>
|
41
|
-
:user_id =>
|
42
|
-
:password =>
|
43
|
-
:project =>
|
44
|
-
:project_domain_id =>
|
39
|
+
:url => 'http://localhost:5000',
|
40
|
+
:user_id => 'user_id',
|
41
|
+
:password => 'secret',
|
42
|
+
:project => 'project',
|
43
|
+
:project_domain_id => 'domain_id'
|
45
44
|
}
|
46
45
|
|
47
|
-
stub_request(:post,
|
46
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
48
47
|
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"id\":\"domain_id\"}}}}}").
|
49
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
48
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
50
49
|
|
51
|
-
Misty::AuthV3.new(auth,
|
50
|
+
Misty::AuthV3.new(auth, config)
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
55
|
-
describe
|
56
|
-
it
|
54
|
+
describe 'with a domain scope' do
|
55
|
+
it 'authenticates using a domain id' do
|
57
56
|
auth = {
|
58
|
-
:url =>
|
59
|
-
:user_id =>
|
60
|
-
:password =>
|
61
|
-
:domain_id =>
|
57
|
+
:url => 'http://localhost:5000',
|
58
|
+
:user_id => 'user_id',
|
59
|
+
:password => 'secret',
|
60
|
+
:domain_id => 'domain_id'
|
62
61
|
}
|
63
62
|
|
64
|
-
stub_request(:post,
|
63
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
65
64
|
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"domain\":{\"id\":\"domain_id\"}}}}").
|
66
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
65
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
67
66
|
|
68
|
-
Misty::AuthV3.new(auth,
|
67
|
+
Misty::AuthV3.new(auth, config)
|
69
68
|
end
|
70
69
|
|
71
|
-
it
|
70
|
+
it 'authenticates using a domain name' do
|
72
71
|
auth = {
|
73
|
-
:url =>
|
74
|
-
:user_id =>
|
75
|
-
:password =>
|
76
|
-
:domain =>
|
72
|
+
:url => 'http://localhost:5000',
|
73
|
+
:user_id => 'user_id',
|
74
|
+
:password => 'secret',
|
75
|
+
:domain => 'domain'
|
77
76
|
}
|
78
77
|
|
79
|
-
stub_request(:post,
|
78
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
80
79
|
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"domain\":{\"name\":\"domain\"}}}}").
|
81
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
80
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
82
81
|
|
83
|
-
Misty::AuthV3.new(auth,
|
82
|
+
Misty::AuthV3.new(auth, config)
|
84
83
|
end
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
88
|
-
describe
|
89
|
-
describe
|
90
|
-
it
|
87
|
+
describe 'using the token method' do
|
88
|
+
describe 'with a project scope' do
|
89
|
+
it 'authenticates using a project id' do
|
91
90
|
auth = {
|
92
|
-
:url =>
|
93
|
-
:token =>
|
94
|
-
:project_id =>
|
91
|
+
:url => 'http://localhost:5000',
|
92
|
+
:token => 'token',
|
93
|
+
:project_id => 'project_id'
|
95
94
|
}
|
96
95
|
|
97
|
-
stub_request(:post,
|
96
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
98
97
|
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"project\":{\"id\":\"project_id\"}}}}").
|
99
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
98
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
100
99
|
|
101
|
-
Misty::AuthV3.new(auth,
|
100
|
+
Misty::AuthV3.new(auth, config)
|
102
101
|
end
|
103
102
|
|
104
|
-
it
|
103
|
+
it 'authenticates using a project name and a project domain id' do
|
105
104
|
auth = {
|
106
|
-
:url =>
|
107
|
-
:token =>
|
108
|
-
:project =>
|
109
|
-
:project_domain_id =>
|
105
|
+
:url => 'http://localhost:5000',
|
106
|
+
:token => 'token',
|
107
|
+
:project => 'project',
|
108
|
+
:project_domain_id => 'domain_id'
|
110
109
|
}
|
111
110
|
|
112
|
-
stub_request(:post,
|
111
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
113
112
|
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"id\":\"domain_id\"}}}}}").
|
114
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
113
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
115
114
|
|
116
|
-
Misty::AuthV3.new(auth,
|
115
|
+
Misty::AuthV3.new(auth, config)
|
117
116
|
end
|
118
117
|
end
|
119
118
|
|
120
|
-
describe
|
121
|
-
it
|
119
|
+
describe 'with a domain scope' do
|
120
|
+
it 'authenticates using a domain id' do
|
122
121
|
auth = {
|
123
|
-
:url =>
|
124
|
-
:token =>
|
125
|
-
:domain_id =>
|
122
|
+
:url => 'http://localhost:5000',
|
123
|
+
:token => 'token',
|
124
|
+
:domain_id => 'domain_id'
|
126
125
|
}
|
127
126
|
|
128
|
-
stub_request(:post,
|
127
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
129
128
|
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"domain\":{\"id\":\"domain_id\"}}}}").
|
130
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
129
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
131
130
|
|
132
|
-
Misty::AuthV3.new(auth,
|
131
|
+
Misty::AuthV3.new(auth, config)
|
133
132
|
end
|
134
133
|
|
135
|
-
it
|
134
|
+
it 'authenticates using a domain name' do
|
136
135
|
auth = {
|
137
|
-
:url =>
|
138
|
-
:token =>
|
139
|
-
:domain =>
|
136
|
+
:url => 'http://localhost:5000',
|
137
|
+
:token => 'token',
|
138
|
+
:domain => 'domain'
|
140
139
|
}
|
141
140
|
|
142
|
-
stub_request(:post,
|
141
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
143
142
|
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"domain\":{\"name\":\"domain\"}}}}").
|
144
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
143
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
145
144
|
|
146
|
-
Misty::AuthV3.new(auth,
|
145
|
+
Misty::AuthV3.new(auth, config)
|
147
146
|
end
|
148
147
|
end
|
149
148
|
end
|
150
149
|
end
|
151
150
|
|
152
|
-
describe
|
151
|
+
describe 'when authenticated' do
|
153
152
|
let(:authv3_creds) do
|
154
153
|
{
|
155
|
-
:url =>
|
156
|
-
:user =>
|
157
|
-
:password =>
|
158
|
-
:project =>
|
154
|
+
:url => 'http://localhost:5000',
|
155
|
+
:user => 'admin',
|
156
|
+
:password => 'secret',
|
157
|
+
:project => 'admin',
|
159
158
|
:project_domain_id=> 'default'
|
160
159
|
}
|
161
160
|
end
|
162
161
|
|
163
|
-
it
|
164
|
-
stub_request(:post,
|
165
|
-
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {
|
162
|
+
it '#get_token' do
|
163
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
164
|
+
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
|
166
165
|
|
167
|
-
auth = Misty::AuthV3.new(authv3_creds,
|
166
|
+
auth = Misty::AuthV3.new(authv3_creds, config)
|
168
167
|
auth.stub :expired?, false do
|
169
|
-
auth.get_token.must_equal
|
168
|
+
auth.get_token.must_equal 'token_data'
|
170
169
|
end
|
171
170
|
end
|
172
171
|
|
173
|
-
it
|
174
|
-
stub_request(:post,
|
175
|
-
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {
|
172
|
+
it '#catalog' do
|
173
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
174
|
+
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
|
176
175
|
|
177
|
-
auth = Misty::AuthV3.new(authv3_creds,
|
178
|
-
auth.catalog.must_equal [
|
176
|
+
auth = Misty::AuthV3.new(authv3_creds, config)
|
177
|
+
auth.catalog.must_equal ['catalog_data']
|
179
178
|
end
|
180
179
|
|
181
|
-
it
|
182
|
-
stub_request(:post,
|
183
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {
|
180
|
+
it '#get_endpoint' do
|
181
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
182
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {'x-subject-token'=>'token_data'})
|
184
183
|
|
185
|
-
auth = Misty::AuthV3.new(authv3_creds,
|
186
|
-
auth.get_endpoint(%w{identity},
|
184
|
+
auth = Misty::AuthV3.new(authv3_creds, config)
|
185
|
+
auth.get_endpoint(%w{identity}, 'regionOne', 'public').must_equal 'http://localhost'
|
187
186
|
end
|
188
187
|
end
|
189
188
|
end
|
190
189
|
|
191
190
|
describe Misty::AuthV2 do
|
192
|
-
describe
|
193
|
-
it
|
194
|
-
stub_request(:post,
|
191
|
+
describe '#new' do
|
192
|
+
it 'fails when missing credentials' do
|
193
|
+
stub_request(:post, 'http://localhost:5000/v2.0/tokens').
|
195
194
|
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {})
|
196
195
|
|
197
196
|
proc do
|
198
|
-
Misty::AuthV2.new({},
|
199
|
-
end.must_raise Misty::Auth::
|
197
|
+
Misty::AuthV2.new({}, config)
|
198
|
+
end.must_raise Misty::Auth::URLError
|
200
199
|
end
|
201
200
|
|
202
|
-
describe
|
203
|
-
it
|
201
|
+
describe 'using the password method' do
|
202
|
+
it 'authenticates using the tenant name' do
|
204
203
|
auth = {
|
205
|
-
:url =>
|
206
|
-
:user =>
|
207
|
-
:password =>
|
208
|
-
:tenant =>
|
204
|
+
:url => 'http://localhost:5000',
|
205
|
+
:user => 'user',
|
206
|
+
:password => 'secret',
|
207
|
+
:tenant => 'tenant',
|
209
208
|
}
|
210
209
|
|
211
|
-
stub_request(:post,
|
210
|
+
stub_request(:post, 'http://localhost:5000/v2.0/tokens').
|
212
211
|
with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantName\":\"tenant\"}}").
|
213
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v2(
|
212
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
|
214
213
|
|
215
|
-
Misty::AuthV2.new(auth,
|
214
|
+
Misty::AuthV2.new(auth, config)
|
216
215
|
end
|
217
216
|
|
218
|
-
it
|
217
|
+
it 'authenticates using the tenant id' do
|
219
218
|
auth = {
|
220
|
-
:url =>
|
221
|
-
:user =>
|
222
|
-
:password =>
|
223
|
-
:tenant_id =>
|
219
|
+
:url => 'http://localhost:5000',
|
220
|
+
:user => 'user',
|
221
|
+
:password => 'secret',
|
222
|
+
:tenant_id => 'tenant_id',
|
224
223
|
}
|
225
224
|
|
226
|
-
stub_request(:post,
|
225
|
+
stub_request(:post, 'http://localhost:5000/v2.0/tokens').
|
227
226
|
with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantId\":\"tenant_id\"}}").
|
228
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v2(
|
227
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
|
229
228
|
|
230
|
-
Misty::AuthV2.new(auth,
|
229
|
+
Misty::AuthV2.new(auth, config)
|
231
230
|
end
|
232
231
|
end
|
233
232
|
|
234
|
-
describe
|
235
|
-
it
|
233
|
+
describe 'using the token method' do
|
234
|
+
it 'authenticates using the tenant name' do
|
236
235
|
auth = {
|
237
|
-
:url =>
|
238
|
-
:token =>
|
239
|
-
:tenant =>
|
236
|
+
:url => 'http://localhost:5000',
|
237
|
+
:token => 'token_id',
|
238
|
+
:tenant => 'tenant',
|
240
239
|
}
|
241
240
|
|
242
|
-
stub_request(:post,
|
241
|
+
stub_request(:post, 'http://localhost:5000/v2.0/tokens').
|
243
242
|
with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantName\":\"tenant\"}}").
|
244
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v2(
|
243
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
|
245
244
|
|
246
|
-
Misty::AuthV2.new(auth,
|
245
|
+
Misty::AuthV2.new(auth, config)
|
247
246
|
end
|
248
247
|
|
249
|
-
it
|
248
|
+
it 'authenticates using the tenant id' do
|
250
249
|
auth = {
|
251
|
-
:url =>
|
252
|
-
:token =>
|
253
|
-
:tenant_id =>
|
250
|
+
:url => 'http://localhost:5000',
|
251
|
+
:token => 'token_id',
|
252
|
+
:tenant_id => 'tenant_id',
|
254
253
|
}
|
255
254
|
|
256
|
-
stub_request(:post,
|
255
|
+
stub_request(:post, 'http://localhost:5000/v2.0/tokens').
|
257
256
|
with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantId\":\"tenant_id\"}}").
|
258
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v2(
|
257
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
|
259
258
|
|
260
|
-
Misty::AuthV2.new(auth,
|
259
|
+
Misty::AuthV2.new(auth, config)
|
261
260
|
end
|
262
261
|
end
|
263
262
|
end
|
264
263
|
|
265
|
-
describe
|
264
|
+
describe 'when authenticated' do
|
266
265
|
let(:authv2_creds) do
|
267
266
|
{
|
268
|
-
:url =>
|
269
|
-
:user =>
|
270
|
-
:password =>
|
271
|
-
:tenant =>
|
267
|
+
:url => 'http://localhost:5000',
|
268
|
+
:user => 'admin',
|
269
|
+
:password => 'secret',
|
270
|
+
:tenant => 'admin'
|
272
271
|
}
|
273
272
|
end
|
274
273
|
|
275
|
-
it
|
276
|
-
stub_request(:post,
|
274
|
+
it '#get_token' do
|
275
|
+
stub_request(:post, 'http://localhost:5000/v2.0/tokens').
|
277
276
|
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
|
278
277
|
|
279
|
-
auth = Misty::AuthV2.new(authv2_creds,
|
278
|
+
auth = Misty::AuthV2.new(authv2_creds, config)
|
280
279
|
auth.stub :expired?, false do
|
281
|
-
auth.get_token.must_equal
|
280
|
+
auth.get_token.must_equal 'token_data'
|
282
281
|
end
|
283
282
|
end
|
284
283
|
|
285
|
-
it
|
286
|
-
stub_request(:post,
|
284
|
+
it '#catalog' do
|
285
|
+
stub_request(:post, 'http://localhost:5000/v2.0/tokens').
|
287
286
|
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
|
288
287
|
|
289
|
-
auth = Misty::AuthV2.new(authv2_creds,
|
290
|
-
auth.catalog.must_equal [
|
288
|
+
auth = Misty::AuthV2.new(authv2_creds, config)
|
289
|
+
auth.catalog.must_equal ['catalog_data']
|
291
290
|
end
|
292
291
|
|
293
|
-
it
|
294
|
-
stub_request(:post,
|
295
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v2(
|
292
|
+
it '#get_endpoint' do
|
293
|
+
stub_request(:post, 'http://localhost:5000/v2.0/tokens').
|
294
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
296
295
|
|
297
|
-
auth = Misty::AuthV2.new(authv2_creds,
|
298
|
-
auth.get_endpoint(%w{identity},
|
296
|
+
auth = Misty::AuthV2.new(authv2_creds, config)
|
297
|
+
auth.get_endpoint(%w{identity}, 'regionOne', 'public').must_equal 'http://localhost'
|
299
298
|
end
|
300
299
|
end
|
301
300
|
end
|
@@ -4,111 +4,111 @@ require 'auth_helper'
|
|
4
4
|
describe Misty::Cloud do
|
5
5
|
let(:cloud) do
|
6
6
|
auth = {
|
7
|
-
:url =>
|
8
|
-
:user =>
|
9
|
-
:password =>
|
10
|
-
:project =>
|
7
|
+
:url => 'http://localhost:5000',
|
8
|
+
:user => 'admin',
|
9
|
+
:password => 'secret',
|
10
|
+
:project => 'admin',
|
11
11
|
:project_domain_id => 'default',
|
12
|
-
:domain =>
|
12
|
+
:domain => 'default'
|
13
13
|
}
|
14
14
|
|
15
15
|
Misty::Cloud.new(:auth => auth)
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
it
|
20
|
-
stub_request(:post,
|
21
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
18
|
+
describe 'GET request' do
|
19
|
+
it 'success without elements in path' do
|
20
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
21
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('network', 'neutron')), :headers => {'x-subject-token'=>'token_data'})
|
22
22
|
|
23
|
-
stub_request(:get,
|
24
|
-
to_return(:status => 200, :body =>
|
23
|
+
stub_request(:get, 'http://localhost/v2.0/networks').
|
24
|
+
to_return(:status => 200, :body => 'list of networks', :headers => {})
|
25
25
|
|
26
26
|
cloud.network.list_networks.response.must_be_kind_of Net::HTTPOK
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
30
|
-
stub_request(:post,
|
31
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
29
|
+
it 'success adds the query option in path' do
|
30
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
31
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('network', 'neutron')), :headers => {'x-subject-token'=>'token_data'})
|
32
32
|
|
33
|
-
stub_request(:get,
|
34
|
-
to_return(:status => 200, :body =>
|
33
|
+
stub_request(:get, 'http://localhost/v2.0/networks?name=value').
|
34
|
+
to_return(:status => 200, :body => 'list of networks', :headers => {})
|
35
35
|
|
36
|
-
cloud.network.list_networks(
|
36
|
+
cloud.network.list_networks('name=value').response.must_be_kind_of Net::HTTPOK
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
40
|
-
stub_request(:post,
|
41
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
39
|
+
it 'successful whith elements in path' do
|
40
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
41
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('image', 'glance')), :headers => {'x-subject-token'=>'token_data'})
|
42
42
|
|
43
|
-
stub_request(:get,
|
44
|
-
to_return(:status => 200, :body =>
|
43
|
+
stub_request(:get, 'http://localhost/v2/images/id1/members/id2').
|
44
|
+
to_return(:status => 200, :body => 'list of images', :headers => {})
|
45
45
|
|
46
|
-
cloud.image.show_image_member_details(
|
46
|
+
cloud.image.show_image_member_details('id1', 'id2').response.must_be_kind_of Net::HTTPOK
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
49
|
+
it 'fails when not enough arguments' do
|
50
50
|
proc do
|
51
|
-
#
|
52
|
-
stub_request(:post,
|
53
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
51
|
+
# '/v2/images/{image_id}/members/{member_id}'
|
52
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
53
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('image', 'glance')), :headers => {'x-subject-token'=>'token_data'})
|
54
54
|
|
55
|
-
cloud.image.show_image_member_details(
|
55
|
+
cloud.image.show_image_member_details('id1')
|
56
56
|
end.must_raise ArgumentError
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe
|
61
|
-
it
|
62
|
-
stub_request(:post,
|
63
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
60
|
+
describe 'POST request' do
|
61
|
+
it 'successful without elements in path' do
|
62
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
63
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
64
64
|
|
65
|
-
stub_request(:post,
|
66
|
-
to_return(:status => 201, :body =>
|
65
|
+
stub_request(:post, 'http://localhost/v3/projects').
|
66
|
+
to_return(:status => 201, :body => 'list of projects', :headers => {})
|
67
67
|
|
68
68
|
cloud.identity.create_project("{\"project\":{\"name\":\"value\"}}").response.must_be_kind_of Net::HTTPCreated
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
72
|
-
stub_request(:post,
|
73
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
71
|
+
it 'sucessful whith elements in pathwhith elements in path' do
|
72
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
73
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('orchestration', 'heat')), :headers => {'x-subject-token'=>'token_data'})
|
74
74
|
|
75
|
-
stub_request(:post,
|
76
|
-
to_return(:status => 201, :body =>
|
75
|
+
stub_request(:post, 'http://localhost/stacks/id1/id2/snapshots').
|
76
|
+
to_return(:status => 201, :body => 'snapshots', :headers => {})
|
77
77
|
|
78
|
-
cloud.orchestration.snapshot_a_stack(
|
78
|
+
cloud.orchestration.snapshot_a_stack('id1', 'id2', "{\"key\": \"value\"}").response.must_be_kind_of Net::HTTPCreated
|
79
79
|
end
|
80
80
|
|
81
|
-
it
|
81
|
+
it 'fails when not enough arguments' do
|
82
82
|
proc do
|
83
|
-
stub_request(:post,
|
84
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
83
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
84
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('orchestration', 'heat')), :headers => {'x-subject-token'=>'token_data'})
|
85
85
|
|
86
|
-
cloud.orchestration.snapshot_a_stack(
|
86
|
+
cloud.orchestration.snapshot_a_stack('id1')
|
87
87
|
end.must_raise ArgumentError
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
describe
|
92
|
-
it
|
93
|
-
stub_request(:post,
|
94
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
91
|
+
describe 'DELETE request' do
|
92
|
+
it 'success' do
|
93
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
94
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
95
95
|
|
96
|
-
stub_request(:delete,
|
97
|
-
to_return(:status => 204, :body =>
|
96
|
+
stub_request(:delete, 'http://localhost/v3/projects/project_id').
|
97
|
+
to_return(:status => 204, :body => 'list of projects', :headers => {})
|
98
98
|
|
99
|
-
cloud.identity.delete_project(
|
99
|
+
cloud.identity.delete_project('project_id').response.must_be_kind_of Net::HTTPNoContent
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
describe
|
104
|
-
it
|
105
|
-
stub_request(:post,
|
106
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3(
|
103
|
+
describe 'PUT request' do
|
104
|
+
it 'success' do
|
105
|
+
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
106
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
107
107
|
|
108
|
-
stub_request(:put,
|
109
|
-
to_return(:status => 200, :body =>
|
108
|
+
stub_request(:put, 'http://localhost/v3/domains/domain_id/groups/group_id/roles/roles_id').
|
109
|
+
to_return(:status => 200, :body => 'list of group/role for a domain', :headers => {})
|
110
110
|
|
111
|
-
cloud.identity.assign_role_to_group_on_domain(
|
111
|
+
cloud.identity.assign_role_to_group_on_domain('domain_id', 'group_id', 'roles_id').response.must_be_kind_of Net::HTTPOK
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|