ruby-keystone-client 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +102 -0
- data/Rakefile +6 -0
- data/lib/keystone/v2_0/client.rb +89 -0
- data/lib/keystone/v2_0/manager/base.rb +63 -0
- data/lib/keystone/v2_0/manager/endpoint.rb +53 -0
- data/lib/keystone/v2_0/manager/role.rb +33 -0
- data/lib/keystone/v2_0/manager/service.rb +50 -0
- data/lib/keystone/v2_0/manager/tenant.rb +33 -0
- data/lib/keystone/v2_0/manager/user.rb +33 -0
- data/lib/keystone/v2_0/resource/base.rb +19 -0
- data/lib/keystone/v2_0/resource/endpoint.rb +29 -0
- data/lib/keystone/v2_0/resource/role.rb +23 -0
- data/lib/keystone/v2_0/resource/service.rb +25 -0
- data/lib/keystone/v2_0/resource/tenant.rb +23 -0
- data/lib/keystone/v2_0/resource/user.rb +25 -0
- data/lib/keystone/v2_0/version.rb +5 -0
- data/ruby-keystone-client.gemspec +28 -0
- data/spec/features/client_spec.rb +63 -0
- data/spec/features/manager/base_spec.rb +50 -0
- data/spec/features/manager/endpoint_spec.rb +120 -0
- data/spec/features/manager/role_spec.rb +44 -0
- data/spec/features/manager/service_spec.rb +91 -0
- data/spec/features/manager/tenant_spec.rb +42 -0
- data/spec/features/manager/user_spec.rb +43 -0
- data/spec/features/resource/endpoint_spec.rb +60 -0
- data/spec/features/resource/role_spec.rb +42 -0
- data/spec/features/resource/service_spec.rb +48 -0
- data/spec/features/resource/tenant_spec.rb +42 -0
- data/spec/features/resource/user_spec.rb +48 -0
- data/spec/spec_helper.rb +14 -0
- metadata +177 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'keystone/v2_0/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruby-keystone-client"
|
8
|
+
spec.version = Keystone::V2_0::VERSION
|
9
|
+
spec.authors = ["Justin Karimi"]
|
10
|
+
spec.email = ["jekhokie@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby OpenStack Keystone Client (API V2.0).}
|
12
|
+
spec.description = %q{A Ruby-based client library to interact with the Keystone service.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "Apache 2.0"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "rest-client"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "simplecov"
|
27
|
+
spec.add_development_dependency "fakeweb"
|
28
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/client"
|
3
|
+
|
4
|
+
describe "Keystone V2.0 client" do
|
5
|
+
let(:username) { "admin" }
|
6
|
+
let(:password) { "admin" }
|
7
|
+
let(:tenant_name) { "admin" }
|
8
|
+
let(:auth_url) { "http://some.host:35357/v2.0" }
|
9
|
+
let(:client) { Keystone::V2_0::Client.new(username, password, tenant_name, auth_url) }
|
10
|
+
let(:token_id) { "FGGRGBLRHGLISH988GE" }
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
FakeWeb.clean_registry
|
14
|
+
FakeWeb.register_uri(:post, "#{auth_url}/tokens", :body => "{\"access\":{\"token\":{\"id\":\"#{token_id}\"}}}")
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "initialize" do
|
18
|
+
it "returns an instance when created with parameters" do
|
19
|
+
expect(client).to be_instance_of(Keystone::V2_0::Client)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "dynamically creates manager methods for each query type" do
|
23
|
+
expect(client).to respond_to(:user_interface)
|
24
|
+
expect(client).to respond_to(:role_interface)
|
25
|
+
expect(client).to respond_to(:tenant_interface)
|
26
|
+
expect(client).to respond_to(:service_interface)
|
27
|
+
expect(client).to respond_to(:endpoint_interface)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns an Array of query results when the query type is invoked" do
|
31
|
+
data = "{ \"users\": [
|
32
|
+
{ \"username\": \"admin\",
|
33
|
+
\"name\": \"admin\",
|
34
|
+
\"enabled\": true,
|
35
|
+
\"email\": null,
|
36
|
+
\"id\": \"49f544c6b0d0403b97d90fe0ee0b585f\" }
|
37
|
+
]
|
38
|
+
}"
|
39
|
+
FakeWeb.register_uri(:get, "#{auth_url}/users", :status => [ 200 ], :body => data)
|
40
|
+
expect(client.user_interface.list).to be_instance_of(Array)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "retuns an exception when no token can be retrieved for the query type" do
|
44
|
+
FakeWeb.clean_registry
|
45
|
+
FakeWeb.register_uri(:post, "#{auth_url}/tokens", :status => [ 404 ], :body => "")
|
46
|
+
expect {
|
47
|
+
client.user_interface.list
|
48
|
+
}.to raise_error
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "get_token" do
|
53
|
+
it "returns a token for querying" do
|
54
|
+
expect(client.send(:get_token)).to eq(token_id)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns nil when no token can be retrieved" do
|
58
|
+
FakeWeb.clean_registry
|
59
|
+
FakeWeb.register_uri(:post, "#{auth_url}/tokens", :status => [ 404 ], :body => "")
|
60
|
+
expect(client.send(:get_token)).to eq(nil)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/manager/base"
|
3
|
+
require "rest-client"
|
4
|
+
|
5
|
+
describe "Keystone V2.0 base manager" do
|
6
|
+
let(:host) { "some.host" }
|
7
|
+
let(:url_endpoint) { "/base/endpoint" }
|
8
|
+
let(:priv_port) { "35357" }
|
9
|
+
let(:auth_url) { "http://#{host}:#{priv_port}/v2.0/" }
|
10
|
+
let(:base_client) { Keystone::V2_0::Manager::Base.new(auth_url, url_endpoint) }
|
11
|
+
let(:endpoint_data) { "{ \"blah\": [
|
12
|
+
{ \"adminurl\": \"http://#{host}:#{priv_port}/v2.0\",
|
13
|
+
\"service_id\": \"876fce0975f841fdbebd8352acda75f4\",
|
14
|
+
\"region\": \"regionOne\",
|
15
|
+
\"publicurl\": \"http://#{host}:5000/v2.0\",
|
16
|
+
\"enabled\": true,
|
17
|
+
\"id\": \"a584ab022f0348ab9335fa2468960578\",
|
18
|
+
\"internalurl\": \"http://#{host}:5000/v2.0\" }
|
19
|
+
]
|
20
|
+
}"
|
21
|
+
}
|
22
|
+
|
23
|
+
describe "initialize" do
|
24
|
+
it "returns an instance when initialized with a URL" do
|
25
|
+
expect(base_client).to be_instance_of(Keystone::V2_0::Manager::Base)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sets the auth_url on create" do
|
29
|
+
expect(base_client.auth_url).to eq(auth_url)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "sets the url_endpoint on create" do
|
33
|
+
expect(base_client.url_endpoint).to eq(url_endpoint)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "list" do
|
38
|
+
it "returns JSON content when query is successful" do
|
39
|
+
FakeWeb.clean_registry
|
40
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 200 ], :body => endpoint_data)
|
41
|
+
expect(base_client.send(:list)).to eq(JSON.parse(endpoint_data))
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns nil when the query is unsuccessful" do
|
45
|
+
FakeWeb.clean_registry
|
46
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 404 ], :body => "")
|
47
|
+
expect(base_client.send(:list)).to eq(nil)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/manager/endpoint"
|
3
|
+
|
4
|
+
describe "Keystone V2.0 endpoint manager" do
|
5
|
+
let(:host) { "some.host" }
|
6
|
+
let(:priv_port) { "35357" }
|
7
|
+
let(:auth_url) { "http://#{host}:#{priv_port}/v2.0/" }
|
8
|
+
let(:endpoint_client) { Keystone::V2_0::Manager::Endpoint.new(auth_url) }
|
9
|
+
let(:url_endpoint) { endpoint_client.url_endpoint }
|
10
|
+
let(:endpoints_data) { "{ \"endpoints\": [
|
11
|
+
{ \"adminurl\": \"http://#{host}:#{priv_port}/v2.0\",
|
12
|
+
\"service_id\": \"876fce0975f841fdbebd8352acda75f4\",
|
13
|
+
\"region\": \"regionOne\",
|
14
|
+
\"publicurl\": \"http://#{host}:5000/v2.0\",
|
15
|
+
\"enabled\": true,
|
16
|
+
\"id\": \"a584ab022f0348ab9335fa2468960578\",
|
17
|
+
\"internalurl\": \"http://#{host}:5000/v2.0\" }
|
18
|
+
]
|
19
|
+
}"
|
20
|
+
}
|
21
|
+
|
22
|
+
describe "initialize" do
|
23
|
+
it "returns an instance when initialized with a URL" do
|
24
|
+
expect(endpoint_client).to be_instance_of(Keystone::V2_0::Manager::Endpoint)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "sets the url_endpoint on create" do
|
28
|
+
expect(endpoint_client.url_endpoint).to be_truthy
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "list" do
|
33
|
+
it "returns a list of Endpoint instances on successful query" do
|
34
|
+
FakeWeb.clean_registry
|
35
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 200 ], :body => endpoints_data)
|
36
|
+
expect(endpoint_client.list.map(&:class)).to eq([ Keystone::V2_0::Resource::Endpoint ])
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns nil when query is unsuccessful" do
|
40
|
+
FakeWeb.clean_registry
|
41
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 404 ], :body => "")
|
42
|
+
expect(endpoint_client.list).to eq(nil)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "create" do
|
47
|
+
let(:service_id) { "93092u092305920395" }
|
48
|
+
let(:region) { "test" }
|
49
|
+
let(:admin_url) { "/something_else" }
|
50
|
+
let(:internal_url) { "/something" }
|
51
|
+
let(:public_url) { "/something" }
|
52
|
+
let(:enabled) { true }
|
53
|
+
let(:endpoint_data) { "{ \"endpoint\":
|
54
|
+
{ \"adminurl\": \"#{admin_url}\",
|
55
|
+
\"service_id\": \"#{service_id}\",
|
56
|
+
\"region\": \"#{region}\",
|
57
|
+
\"enabled\": #{enabled},
|
58
|
+
\"id\": \"q93h08923hg02h03929350h\",
|
59
|
+
\"internalurl\": \"#{internal_url}\",
|
60
|
+
\"publicurl\": \"#{public_url}\" }
|
61
|
+
}" }
|
62
|
+
|
63
|
+
describe "when successful" do
|
64
|
+
before do
|
65
|
+
FakeWeb.clean_registry
|
66
|
+
FakeWeb.register_uri(:post, "#{auth_url}#{url_endpoint}", :status => [ 200 ], :body => endpoint_data)
|
67
|
+
@endpoint = endpoint_client.create(service_id: service_id,
|
68
|
+
region: region,
|
69
|
+
admin_url: admin_url,
|
70
|
+
internal_url: internal_url,
|
71
|
+
public_url: public_url,
|
72
|
+
enabled: enabled)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "returns a Service instance" do
|
76
|
+
expect(@endpoint).to be_instance_of(Keystone::V2_0::Resource::Endpoint)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "assigns an ID" do
|
80
|
+
expect(@endpoint.id).to be_truthy
|
81
|
+
end
|
82
|
+
|
83
|
+
it "assigns the service_id" do
|
84
|
+
expect(@endpoint.service_id).to eq(service_id)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "assigns the region" do
|
88
|
+
expect(@endpoint.region).to eq(region)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "assigns the admin_url" do
|
92
|
+
expect(@endpoint.admin_url).to eq(admin_url)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "assigns the internal_url" do
|
96
|
+
expect(@endpoint.internal_url).to eq(internal_url)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "assigns the public_url" do
|
100
|
+
expect(@endpoint.public_url).to eq(public_url)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "assigns enabled" do
|
104
|
+
expect(@endpoint.enabled).to eq(enabled)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it "returns nil when not able to be created" do
|
109
|
+
FakeWeb.clean_registry
|
110
|
+
FakeWeb.register_uri(:post, "#{auth_url}#{url_endpoint}", :status => [ 404 ], :body => "")
|
111
|
+
endpoint = endpoint_client.create(service_id: service_id,
|
112
|
+
region: region,
|
113
|
+
admin_url: admin_url,
|
114
|
+
internal_url: internal_url,
|
115
|
+
public_url: public_url,
|
116
|
+
enabled: enabled)
|
117
|
+
expect(@endpoint).to eq(nil)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/manager/role"
|
3
|
+
|
4
|
+
describe "Keystone V2.0 role manager" do
|
5
|
+
let(:host) { "some.host" }
|
6
|
+
let(:priv_port) { "35357" }
|
7
|
+
let(:auth_url) { "http://#{host}:#{priv_port}/v2.0/" }
|
8
|
+
let(:role_client) { Keystone::V2_0::Manager::Role.new(auth_url) }
|
9
|
+
let(:url_endpoint) { role_client.url_endpoint }
|
10
|
+
let(:roles_data) { "{ \"roles\": [
|
11
|
+
{ \"enabled\": \"True\",
|
12
|
+
\"description\": \"Default role for project membership\",
|
13
|
+
\"name\": \"_member_\",
|
14
|
+
\"id\": \"9fe2ff9ee4384b1894a90878d3e92bab\" },
|
15
|
+
{ \"id\": \"e409aeca08b548ceb94ced546e1a4a18\",
|
16
|
+
\"name\": \"admin\" }
|
17
|
+
]
|
18
|
+
}"
|
19
|
+
}
|
20
|
+
|
21
|
+
describe "initialize" do
|
22
|
+
it "returns an instance when initialized with a URL" do
|
23
|
+
expect(role_client).to be_instance_of(Keystone::V2_0::Manager::Role)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "sets the url_endpoint on create" do
|
27
|
+
expect(role_client.url_endpoint).to be_truthy
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "list" do
|
32
|
+
it "returns a list of Role instances on successful query" do
|
33
|
+
FakeWeb.clean_registry
|
34
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 200 ], :body => roles_data)
|
35
|
+
expect(role_client.list.map(&:class)).to eq([ Keystone::V2_0::Resource::Role, Keystone::V2_0::Resource::Role ])
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns nil when query is unsuccessful" do
|
39
|
+
FakeWeb.clean_registry
|
40
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 404 ], :body => "")
|
41
|
+
expect(role_client.list).to eq(nil)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/manager/service"
|
3
|
+
|
4
|
+
describe "Keystone V2.0 service manager" do
|
5
|
+
let(:host) { "some.host" }
|
6
|
+
let(:priv_port) { "35357" }
|
7
|
+
let(:auth_url) { "http://#{host}:#{priv_port}/v2.0/" }
|
8
|
+
let(:service_client) { Keystone::V2_0::Manager::Service.new(auth_url) }
|
9
|
+
let(:url_endpoint) { service_client.url_endpoint }
|
10
|
+
let(:services_data) { "{ \"OS-KSADM:services\": [
|
11
|
+
{ \"id\": \"876fce0975f841fdbebd8352acda75f4\",
|
12
|
+
\"enabled\": true,
|
13
|
+
\"type\": \"identity\",
|
14
|
+
\"name\": \"keystone\",
|
15
|
+
\"description\": \"Keystone Identity Service\"}
|
16
|
+
]
|
17
|
+
}"
|
18
|
+
}
|
19
|
+
|
20
|
+
describe "initialize" do
|
21
|
+
it "returns an instance when initialized with a URL" do
|
22
|
+
expect(service_client).to be_instance_of(Keystone::V2_0::Manager::Service)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "sets the url_endpoint on create" do
|
26
|
+
expect(service_client.url_endpoint).to be_truthy
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "list" do
|
31
|
+
it "returns a list of Service instances on successful query" do
|
32
|
+
FakeWeb.clean_registry
|
33
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 200 ], :body => services_data)
|
34
|
+
expect(service_client.list.map(&:class)).to eq([ Keystone::V2_0::Resource::Service ])
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns nil when query is unsuccessful" do
|
38
|
+
FakeWeb.clean_registry
|
39
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 404 ], :body => "")
|
40
|
+
expect(service_client.list).to eq(nil)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "create" do
|
45
|
+
let(:name) { "test" }
|
46
|
+
let(:type) { "test tool" }
|
47
|
+
let(:description) { "Some kind of test" }
|
48
|
+
let(:service_data) { "{ \"OS-KSADM:service\":
|
49
|
+
{ \"id\": \"43dc90f2398b4510acc8f07901e30ed8\",
|
50
|
+
\"enabled\": true,
|
51
|
+
\"type\": \"#{type}\",
|
52
|
+
\"name\": \"#{name}\",
|
53
|
+
\"description\": \"#{description}\" }
|
54
|
+
}" }
|
55
|
+
|
56
|
+
describe "when successful" do
|
57
|
+
before do
|
58
|
+
FakeWeb.clean_registry
|
59
|
+
FakeWeb.register_uri(:post, "#{auth_url}#{url_endpoint}", :status => [ 200 ], :body => service_data)
|
60
|
+
@service = service_client.create(name: name, type: type, description: description)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns a Service instance" do
|
64
|
+
expect(@service).to be_instance_of(Keystone::V2_0::Resource::Service)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "assigns an ID" do
|
68
|
+
expect(@service.id).to be_truthy
|
69
|
+
end
|
70
|
+
|
71
|
+
it "assigns the name" do
|
72
|
+
expect(@service.name).to eq(name)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "assigns the type" do
|
76
|
+
expect(@service.type).to eq(type)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "assigns the description" do
|
80
|
+
expect(@service.description).to eq(description)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it "returns nil when not able to be created" do
|
85
|
+
FakeWeb.clean_registry
|
86
|
+
FakeWeb.register_uri(:post, "#{auth_url}#{url_endpoint}", :status => [ 404 ], :body => "")
|
87
|
+
service = service_client.create(name: name, type: type, description: description)
|
88
|
+
expect(@service).to eq(nil)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/manager/tenant"
|
3
|
+
|
4
|
+
describe "Keystone V2.0 tenant manager" do
|
5
|
+
let(:host) { "some.host" }
|
6
|
+
let(:priv_port) { "35357" }
|
7
|
+
let(:auth_url) { "http://#{host}:#{priv_port}/v2.0/" }
|
8
|
+
let(:tenant_client) { Keystone::V2_0::Manager::Tenant.new(auth_url) }
|
9
|
+
let(:url_endpoint) { tenant_client.url_endpoint }
|
10
|
+
let(:tenants_data) { "{ \"tenants\": [
|
11
|
+
{ \"description\": \"Admin Tenant\",
|
12
|
+
\"enabled\": true,
|
13
|
+
\"id\": \"9958cfb44628476b8f16996e76703292\",
|
14
|
+
\"name\": \"admin\" }
|
15
|
+
]
|
16
|
+
}"
|
17
|
+
}
|
18
|
+
|
19
|
+
describe "initialize" do
|
20
|
+
it "returns an instance when initialized with a URL" do
|
21
|
+
expect(tenant_client).to be_instance_of(Keystone::V2_0::Manager::Tenant)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "sets the url_endpoint on create" do
|
25
|
+
expect(tenant_client.url_endpoint).to be_truthy
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "list" do
|
30
|
+
it "returns a list of Tenant instances on successful query" do
|
31
|
+
FakeWeb.clean_registry
|
32
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 200 ], :body => tenants_data)
|
33
|
+
expect(tenant_client.list.map(&:class)).to eq([ Keystone::V2_0::Resource::Tenant ])
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns nil when query is unsuccessful" do
|
37
|
+
FakeWeb.clean_registry
|
38
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 404 ], :body => "")
|
39
|
+
expect(tenant_client.list).to eq(nil)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/manager/user"
|
3
|
+
|
4
|
+
describe "Keystone V2.0 user manager" do
|
5
|
+
let(:host) { "some.host" }
|
6
|
+
let(:priv_port) { "35357" }
|
7
|
+
let(:auth_url) { "http://#{host}:#{priv_port}/v2.0/" }
|
8
|
+
let(:user_client) { Keystone::V2_0::Manager::User.new(auth_url) }
|
9
|
+
let(:url_endpoint) { user_client.url_endpoint }
|
10
|
+
let(:users_data) { "{ \"users\": [
|
11
|
+
{ \"username\": \"admin\",
|
12
|
+
\"name\": \"admin\",
|
13
|
+
\"enabled\": true,
|
14
|
+
\"email\": null,
|
15
|
+
\"id\": \"49f544c6b0d0403b97d90fe0ee0b585f\" }
|
16
|
+
]
|
17
|
+
}"
|
18
|
+
}
|
19
|
+
|
20
|
+
describe "initialize" do
|
21
|
+
it "returns an instance when initialized with a URL" do
|
22
|
+
expect(user_client).to be_instance_of(Keystone::V2_0::Manager::User)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "sets the url_endpoint on create" do
|
26
|
+
expect(user_client.url_endpoint).to be_truthy
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "list" do
|
31
|
+
it "returns a list of User instances on successful query" do
|
32
|
+
FakeWeb.clean_registry
|
33
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 200 ], :body => users_data)
|
34
|
+
expect(user_client.list.map(&:class)).to eq([ Keystone::V2_0::Resource::User ])
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns nil when query is unsuccessful" do
|
38
|
+
FakeWeb.clean_registry
|
39
|
+
FakeWeb.register_uri(:get, "#{auth_url}#{url_endpoint}", :status => [ 404 ], :body => "")
|
40
|
+
expect(user_client.list).to eq(nil)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/resource/endpoint"
|
3
|
+
|
4
|
+
describe "Keystone V2.0 endpoint resource" do
|
5
|
+
let(:admin_url) { "http://some.host:35357/v2.0" }
|
6
|
+
let(:internal_url) { "http://some.host:35357/v2.0" }
|
7
|
+
let(:public_url) { "http://some.host:5000/v2.0" }
|
8
|
+
let(:id) { "w09ehg0923ht9" }
|
9
|
+
let(:enabled) { true }
|
10
|
+
let(:region) { "Region1" }
|
11
|
+
let(:service_id) { "930uty09gh209gh" }
|
12
|
+
let(:endpoint_data) { "{ \"adminurl\": \"#{admin_url}\",
|
13
|
+
\"service_id\": \"#{service_id}\",
|
14
|
+
\"region\": \"#{region}\",
|
15
|
+
\"publicurl\": \"#{public_url}\",
|
16
|
+
\"enabled\": #{enabled},
|
17
|
+
\"id\": \"#{id}\",
|
18
|
+
\"internalurl\": \"#{internal_url}\" }"
|
19
|
+
}
|
20
|
+
|
21
|
+
it "responds with the attribute mappings" do
|
22
|
+
expect(Keystone::V2_0::Resource::Endpoint.attr_mappings).to be_truthy
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "initialize" do
|
26
|
+
let(:resource) { Keystone::V2_0::Resource::Endpoint.new(JSON.parse(endpoint_data)) }
|
27
|
+
|
28
|
+
it "returns an Endpoint resource on initailize" do
|
29
|
+
expect(resource).to be_instance_of(Keystone::V2_0::Resource::Endpoint)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "assigns the admin_url attribute" do
|
33
|
+
expect(resource.admin_url).to eq(admin_url)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "assigns the service_id attribute" do
|
37
|
+
expect(resource.service_id).to eq(service_id)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "assigns the region attribute" do
|
41
|
+
expect(resource.region).to eq(region)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "assigns the public_url attribute" do
|
45
|
+
expect(resource.public_url).to eq(public_url)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "assigns the enabled attribute" do
|
49
|
+
expect(resource.enabled).to eq(enabled)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "assigns the id attribute" do
|
53
|
+
expect(resource.id).to eq(id)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "assigns the internal_url attribute" do
|
57
|
+
expect(resource.internal_url).to eq(internal_url)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/resource/role"
|
3
|
+
|
4
|
+
describe "Keystone V2.0 role resource" do
|
5
|
+
let(:name) { "test" }
|
6
|
+
let(:enabled) { "True" }
|
7
|
+
let(:description) { "testing this out" }
|
8
|
+
let(:id) { "930uty09gh209gh" }
|
9
|
+
let(:role_data) { "{ \"enabled\": \"#{enabled}\",
|
10
|
+
\"description\": \"#{description}\",
|
11
|
+
\"name\": \"#{name}\",
|
12
|
+
\"id\": \"#{id}\" }"
|
13
|
+
}
|
14
|
+
|
15
|
+
it "responds with the attribute mappings" do
|
16
|
+
expect(Keystone::V2_0::Resource::Role.attr_mappings).to be_truthy
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "initialize" do
|
20
|
+
let(:resource) { Keystone::V2_0::Resource::Role.new(JSON.parse(role_data)) }
|
21
|
+
|
22
|
+
it "returns a Role resource on initailize" do
|
23
|
+
expect(resource).to be_instance_of(Keystone::V2_0::Resource::Role)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "assigns the enabled attribute" do
|
27
|
+
expect(resource.enabled).to eq(enabled)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "assigns the description attribute" do
|
31
|
+
expect(resource.description).to eq(description)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "assigns the name attribute" do
|
35
|
+
expect(resource.name).to eq(name)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "assigns the id attribute" do
|
39
|
+
expect(resource.id).to eq(id)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "keystone/v2_0/resource/service"
|
3
|
+
|
4
|
+
describe "Keystone V2.0 service resource" do
|
5
|
+
let(:name) { "keystone" }
|
6
|
+
let(:enabled) { true }
|
7
|
+
let(:type) { "identity" }
|
8
|
+
let(:id) { "930uty09gh209gh" }
|
9
|
+
let(:description) { "testing this out" }
|
10
|
+
let(:service_data) { "{ \"id\": \"#{id}\",
|
11
|
+
\"enabled\": #{enabled},
|
12
|
+
\"type\": \"#{type}\",
|
13
|
+
\"name\": \"#{name}\",
|
14
|
+
\"description\": \"#{description}\"} "
|
15
|
+
}
|
16
|
+
|
17
|
+
it "responds with the attribute mappings" do
|
18
|
+
expect(Keystone::V2_0::Resource::Endpoint.attr_mappings).to be_truthy
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "initialize" do
|
22
|
+
let(:resource) { Keystone::V2_0::Resource::Service.new(JSON.parse(service_data)) }
|
23
|
+
|
24
|
+
it "returns a Service resource on initailize" do
|
25
|
+
expect(resource).to be_instance_of(Keystone::V2_0::Resource::Service)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "assigns the id attribute" do
|
29
|
+
expect(resource.id).to eq(id)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "assigns the enabled attribute" do
|
33
|
+
expect(resource.enabled).to eq(enabled)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "assigns the type attribute" do
|
37
|
+
expect(resource.type).to eq(type)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "assigns the name attribute" do
|
41
|
+
expect(resource.name).to eq(name)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "assigns the description attribute" do
|
45
|
+
expect(resource.description).to eq(description)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|