fog 1.32.0 → 1.33.0
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 +4 -4
- data/CHANGELOG.md +59 -0
- data/Gemfile +1 -0
- data/Rakefile +4 -4
- data/fog.gemspec +3 -2
- data/lib/fog/linode/requests/compute/avail_datacenters.rb +8 -7
- data/lib/fog/openstack.rb +1 -0
- data/lib/fog/openstack/compute.rb +7 -1
- data/lib/fog/openstack/core.rb +28 -54
- data/lib/fog/openstack/identity.rb +1 -0
- data/lib/fog/openstack/identity_v3.rb +10 -9
- data/lib/fog/openstack/models/baremetal/chassis.rb +3 -14
- data/lib/fog/openstack/models/baremetal/chassis_collection.rb +5 -5
- data/lib/fog/openstack/models/baremetal/driver.rb +2 -8
- data/lib/fog/openstack/models/baremetal/drivers.rb +3 -5
- data/lib/fog/openstack/models/baremetal/node.rb +3 -14
- data/lib/fog/openstack/models/baremetal/nodes.rb +4 -4
- data/lib/fog/openstack/models/baremetal/port.rb +3 -14
- data/lib/fog/openstack/models/baremetal/ports.rb +4 -4
- data/lib/fog/openstack/models/collection.rb +45 -0
- data/lib/fog/openstack/models/compute/address.rb +2 -2
- data/lib/fog/openstack/models/compute/addresses.rb +3 -5
- data/lib/fog/openstack/models/compute/aggregate.rb +2 -8
- data/lib/fog/openstack/models/compute/aggregates.rb +3 -5
- data/lib/fog/openstack/models/compute/availability_zone.rb +14 -0
- data/lib/fog/openstack/models/compute/availability_zones.rb +22 -0
- data/lib/fog/openstack/models/compute/flavor.rb +2 -8
- data/lib/fog/openstack/models/compute/flavors.rb +6 -6
- data/lib/fog/openstack/models/compute/host.rb +1 -1
- data/lib/fog/openstack/models/compute/hosts.rb +4 -6
- data/lib/fog/openstack/models/compute/image.rb +2 -8
- data/lib/fog/openstack/models/compute/images.rb +4 -6
- data/lib/fog/openstack/models/compute/key_pair.rb +2 -2
- data/lib/fog/openstack/models/compute/key_pairs.rb +3 -4
- data/lib/fog/openstack/models/compute/metadata.rb +3 -2
- data/lib/fog/openstack/models/compute/metadatum.rb +2 -2
- data/lib/fog/openstack/models/compute/network.rb +2 -2
- data/lib/fog/openstack/models/compute/networks.rb +3 -2
- data/lib/fog/openstack/models/compute/security_group.rb +2 -2
- data/lib/fog/openstack/models/compute/security_group_rule.rb +2 -2
- data/lib/fog/openstack/models/compute/security_group_rules.rb +2 -2
- data/lib/fog/openstack/models/compute/security_groups.rb +3 -5
- data/lib/fog/openstack/models/compute/server.rb +20 -1
- data/lib/fog/openstack/models/compute/servers.rb +9 -5
- data/lib/fog/openstack/models/compute/service.rb +2 -8
- data/lib/fog/openstack/models/compute/services.rb +4 -4
- data/lib/fog/openstack/models/compute/snapshot.rb +2 -8
- data/lib/fog/openstack/models/compute/snapshots.rb +5 -5
- data/lib/fog/openstack/models/compute/tenant.rb +2 -2
- data/lib/fog/openstack/models/compute/tenants.rb +3 -4
- data/lib/fog/openstack/models/compute/volume.rb +2 -8
- data/lib/fog/openstack/models/compute/volumes.rb +5 -5
- data/lib/fog/openstack/models/identity_v2/ec2_credential.rb +3 -9
- data/lib/fog/openstack/models/identity_v2/ec2_credentials.rb +3 -5
- data/lib/fog/openstack/models/identity_v2/role.rb +3 -3
- data/lib/fog/openstack/models/identity_v2/roles.rb +3 -5
- data/lib/fog/openstack/models/identity_v2/tenant.rb +5 -9
- data/lib/fog/openstack/models/identity_v2/tenants.rb +3 -5
- data/lib/fog/openstack/models/identity_v2/user.rb +2 -8
- data/lib/fog/openstack/models/identity_v2/users.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/domain.rb +5 -9
- data/lib/fog/openstack/models/identity_v3/domains.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/endpoint.rb +5 -9
- data/lib/fog/openstack/models/identity_v3/endpoints.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/group.rb +5 -9
- data/lib/fog/openstack/models/identity_v3/groups.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/os_credential.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/os_credentials.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/policies.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/policy.rb +5 -9
- data/lib/fog/openstack/models/identity_v3/project.rb +5 -8
- data/lib/fog/openstack/models/identity_v3/projects.rb +21 -10
- data/lib/fog/openstack/models/identity_v3/role.rb +3 -8
- data/lib/fog/openstack/models/identity_v3/role_assignment.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/role_assignments.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/roles.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/service.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/services.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/token.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/tokens.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/user.rb +3 -9
- data/lib/fog/openstack/models/identity_v3/users.rb +3 -5
- data/lib/fog/openstack/models/image/image.rb +2 -13
- data/lib/fog/openstack/models/image/images.rb +5 -5
- data/lib/fog/openstack/models/metering/resource.rb +2 -7
- data/lib/fog/openstack/models/metering/resources.rb +3 -3
- data/lib/fog/openstack/models/model.rb +44 -0
- data/lib/fog/openstack/models/network/floating_ip.rb +2 -7
- data/lib/fog/openstack/models/network/floating_ips.rb +3 -5
- data/lib/fog/openstack/models/network/lb_health_monitor.rb +2 -12
- data/lib/fog/openstack/models/network/lb_health_monitors.rb +3 -5
- data/lib/fog/openstack/models/network/lb_member.rb +2 -12
- data/lib/fog/openstack/models/network/lb_members.rb +3 -5
- data/lib/fog/openstack/models/network/lb_pool.rb +2 -12
- data/lib/fog/openstack/models/network/lb_pools.rb +3 -5
- data/lib/fog/openstack/models/network/lb_vip.rb +2 -12
- data/lib/fog/openstack/models/network/lb_vips.rb +3 -5
- data/lib/fog/openstack/models/network/network.rb +2 -12
- data/lib/fog/openstack/models/network/networks.rb +3 -5
- data/lib/fog/openstack/models/network/port.rb +2 -13
- data/lib/fog/openstack/models/network/ports.rb +3 -5
- data/lib/fog/openstack/models/network/router.rb +2 -13
- data/lib/fog/openstack/models/network/routers.rb +3 -5
- data/lib/fog/openstack/models/network/security_group.rb +2 -2
- data/lib/fog/openstack/models/network/security_group_rule.rb +2 -2
- data/lib/fog/openstack/models/network/security_group_rules.rb +3 -5
- data/lib/fog/openstack/models/network/security_groups.rb +3 -5
- data/lib/fog/openstack/models/network/subnet.rb +3 -14
- data/lib/fog/openstack/models/network/subnets.rb +3 -5
- data/lib/fog/openstack/models/orchestration/event.rb +2 -2
- data/lib/fog/openstack/models/orchestration/events.rb +5 -7
- data/lib/fog/openstack/models/orchestration/resource.rb +2 -2
- data/lib/fog/openstack/models/orchestration/resource_schemas.rb +2 -2
- data/lib/fog/openstack/models/orchestration/resources.rb +3 -5
- data/lib/fog/openstack/models/orchestration/stack.rb +3 -7
- data/lib/fog/openstack/models/orchestration/stacks.rb +5 -5
- data/lib/fog/openstack/models/orchestration/template.rb +2 -2
- data/lib/fog/openstack/models/orchestration/templates.rb +1 -1
- data/lib/fog/openstack/models/planning/plan.rb +2 -13
- data/lib/fog/openstack/models/planning/plans.rb +3 -5
- data/lib/fog/openstack/models/planning/role.rb +2 -8
- data/lib/fog/openstack/models/planning/roles.rb +3 -6
- data/lib/fog/openstack/models/storage/directories.rb +4 -6
- data/lib/fog/openstack/models/storage/directory.rb +2 -2
- data/lib/fog/openstack/models/storage/file.rb +15 -2
- data/lib/fog/openstack/models/storage/files.rb +7 -8
- data/lib/fog/openstack/models/volume/availability_zone.rb +13 -0
- data/lib/fog/openstack/models/volume/availability_zones.rb +17 -0
- data/lib/fog/openstack/models/volume/transfer.rb +36 -0
- data/lib/fog/openstack/models/volume/transfers.rb +38 -0
- data/lib/fog/openstack/models/volume/volume.rb +9 -8
- data/lib/fog/openstack/models/volume/volume_type.rb +2 -8
- data/lib/fog/openstack/models/volume/volume_types.rb +3 -6
- data/lib/fog/openstack/models/volume/volumes.rb +5 -6
- data/lib/fog/openstack/requests/compute/list_servers.rb +8 -5
- data/lib/fog/openstack/requests/compute/list_servers_detail.rb +9 -6
- data/lib/fog/openstack/requests/compute/list_zones.rb +6 -5
- data/lib/fog/openstack/requests/compute/list_zones_detailed.rb +55 -0
- data/lib/fog/openstack/requests/compute/shelve_offload_server.rb +24 -0
- data/lib/fog/openstack/requests/compute/shelve_server.rb +24 -0
- data/lib/fog/openstack/requests/compute/unshelve_server.rb +24 -0
- data/lib/fog/openstack/requests/identity_v3/get_project.rb +2 -2
- data/lib/fog/openstack/requests/network/create_subnet.rb +1 -1
- data/lib/fog/openstack/requests/network/update_subnet.rb +8 -7
- data/lib/fog/openstack/requests/volume/accept_transfer.rb +24 -0
- data/lib/fog/openstack/requests/volume/create_transfer.rb +27 -0
- data/lib/fog/openstack/requests/volume/delete_transfer.rb +17 -0
- data/lib/fog/openstack/requests/volume/extend_volume.rb +25 -0
- data/lib/fog/openstack/requests/volume/get_transfer_details.rb +17 -0
- data/lib/fog/openstack/requests/volume/list_transfers.rb +18 -0
- data/lib/fog/openstack/requests/volume/list_transfers_detailed.rb +18 -0
- data/lib/fog/openstack/requests/volume/list_zones.rb +32 -0
- data/lib/fog/openstack/storage.rb +3 -1
- data/lib/fog/openstack/volume.rb +16 -0
- data/lib/fog/rackspace/examples/compute_v2/create_network.rb +1 -1
- data/lib/fog/vcloud_director/generators/compute/edge_gateway_service_configuration.rb +31 -30
- data/lib/fog/vcloud_director/models/compute/task.rb +2 -2
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/compute.rb +1 -0
- data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -1
- data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +4 -3
- data/lib/fog/vsphere/requests/compute/list_clusters.rb +1 -1
- data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +101 -30
- data/lib/fog/vsphere/requests/compute/vm_execute.rb +47 -0
- data/lib/tasks/changelog_task.rb +1 -0
- data/spec/fog/openstack/identity_v3/{idv3.yml → common_setup.yml} +0 -0
- data/spec/fog/openstack/identity_v3/idv3_project_hier_crud_list.yml +1394 -0
- data/spec/fog/openstack/identity_v3_spec.rb +255 -196
- data/spec/fog/openstack/network/common_setup.yml +131 -0
- data/spec/fog/openstack/network/subnets_crud.yml +140 -0
- data/spec/fog/openstack/network_spec.rb +43 -0
- data/spec/fog/openstack/shared_context.rb +98 -0
- data/spec/fog/openstack/volume/{volume_common_setup.yml → common_setup.yml} +0 -0
- data/spec/fog/openstack/volume/volume_extend.yml +762 -0
- data/spec/fog/openstack/volume/volume_transfer_and_accept.yml +1078 -0
- data/spec/fog/openstack/volume/volume_transfer_and_delete.yml +695 -0
- data/spec/fog/openstack/volume_spec.rb +232 -67
- data/tests/openstack/models/storage/file_tests.rb +26 -0
- data/tests/openstack/requests/compute/availability_zone_tests.rb +18 -0
- data/tests/openstack/requests/compute/server_tests.rb +12 -0
- data/tests/openstack/requests/network/subnet_tests.rb +2 -2
- data/tests/openstack/requests/volume/availability_zone_tests.rb +13 -0
- data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +2 -2
- metadata +61 -26
- data/lib/fog/dynect.rb +0 -1
- data/lib/fog/dynect/core.rb +0 -26
- data/lib/fog/dynect/dns.rb +0 -157
- data/lib/fog/dynect/models/dns/record.rb +0 -67
- data/lib/fog/dynect/models/dns/records.rb +0 -48
- data/lib/fog/dynect/models/dns/zone.rb +0 -56
- data/lib/fog/dynect/models/dns/zones.rb +0 -25
- data/lib/fog/dynect/requests/dns/delete_record.rb +0 -55
- data/lib/fog/dynect/requests/dns/delete_zone.rb +0 -41
- data/lib/fog/dynect/requests/dns/get_all_records.rb +0 -56
- data/lib/fog/dynect/requests/dns/get_node_list.rb +0 -55
- data/lib/fog/dynect/requests/dns/get_record.rb +0 -83
- data/lib/fog/dynect/requests/dns/get_zone.rb +0 -57
- data/lib/fog/dynect/requests/dns/post_record.rb +0 -71
- data/lib/fog/dynect/requests/dns/post_session.rb +0 -43
- data/lib/fog/dynect/requests/dns/post_zone.rb +0 -70
- data/lib/fog/dynect/requests/dns/put_record.rb +0 -76
- data/lib/fog/dynect/requests/dns/put_zone.rb +0 -76
- data/tests/dynect/requests/dns/dns_tests.rb +0 -258
|
@@ -1,54 +1,20 @@
|
|
|
1
1
|
require 'fog/openstack/identity'
|
|
2
2
|
require 'fog/openstack/identity_v3'
|
|
3
|
-
require 'rspec/core'
|
|
4
|
-
require 'rspec/expectations'
|
|
5
|
-
require 'vcr'
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# if OS_AUTH_URL is set but FOG_MOCK is not, don't record anything and just pass through the requests
|
|
13
|
-
VCR.configure do |c|
|
|
14
|
-
c.ignore_request do |request|
|
|
15
|
-
ENV['FOG_MOCK']!='true' && !ENV['OS_AUTH_URL'].nil?
|
|
16
|
-
end
|
|
17
|
-
end if @os_auth_url
|
|
18
|
-
|
|
19
|
-
# Fail-safe URL which matches the VCR recordings
|
|
20
|
-
@os_auth_url ||= 'http://devstack.openstack.stack:5000/v3'
|
|
21
|
-
|
|
22
|
-
VCR.configure do |config|
|
|
23
|
-
config.allow_http_connections_when_no_cassette = true
|
|
24
|
-
config.hook_into :webmock
|
|
25
|
-
config.cassette_library_dir = "spec/fog/openstack/identity_v3"
|
|
26
|
-
config.default_cassette_options = {:record => :none}
|
|
27
|
-
config.default_cassette_options.merge! :match_requests_on => [:method, :uri, :body] unless RUBY_VERSION =~ /1.8/ # Ruby 1.8.7 encodes JSON differently, which screws up request matching
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
if ENV['DEBUG']
|
|
31
|
-
VCR.configure do |config|
|
|
32
|
-
config.ignore_request do |request|
|
|
33
|
-
false && !ENV['OS_AUTH_URL'].nil?
|
|
34
|
-
end
|
|
35
|
-
config.cassette_library_dir = "spec/debug"
|
|
36
|
-
config.default_cassette_options.merge! :record => :all
|
|
37
|
-
end
|
|
38
|
-
end
|
|
4
|
+
if RUBY_VERSION =~ /1.8/
|
|
5
|
+
require File.expand_path('../shared_context', __FILE__)
|
|
6
|
+
else
|
|
7
|
+
require_relative './shared_context'
|
|
8
|
+
end
|
|
39
9
|
|
|
40
|
-
|
|
41
|
-
Excon.defaults[:ssl_verify_peer] = false if ENV['SSL_VERIFY_PEER'] == 'false'
|
|
10
|
+
RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
42
11
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
:openstack_region => ENV['OS_REGION_NAME'] || 'RegionOne',
|
|
50
|
-
:openstack_auth_url => "#{@os_auth_url}/auth/tokens") unless @id_v3
|
|
51
|
-
end
|
|
12
|
+
include_context 'OpenStack specs with VCR'
|
|
13
|
+
before :all do
|
|
14
|
+
setup_vcr_and_service(
|
|
15
|
+
:vcr_directory => 'spec/fog/openstack/identity_v3',
|
|
16
|
+
:service_class => Fog::Identity::OpenStack::V3
|
|
17
|
+
)
|
|
52
18
|
end
|
|
53
19
|
|
|
54
20
|
it 'authenticates with password, userid and domain_id' do
|
|
@@ -86,7 +52,7 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
86
52
|
|
|
87
53
|
it 'authenticates in another region' do
|
|
88
54
|
VCR.use_cassette('idv3_endpoint') do
|
|
89
|
-
@endpoints_all = @
|
|
55
|
+
@endpoints_all = @service.endpoints.all
|
|
90
56
|
end
|
|
91
57
|
endpoints_in_region = @endpoints_all.select { |endpoint| endpoint.region == (ENV['OS_REGION_OTHER']||'europe') }
|
|
92
58
|
|
|
@@ -104,14 +70,14 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
104
70
|
it 'get an unscoped token, then reauthenticate with it' do
|
|
105
71
|
VCR.use_cassette('authv3_unscoped_reauth') do
|
|
106
72
|
|
|
107
|
-
|
|
73
|
+
id_v3 = Fog::Identity::OpenStack::V3.new(
|
|
108
74
|
:openstack_api_key => ENV['OS_PASSWORD'] || 'password',
|
|
109
75
|
:openstack_userid => ENV['OS_USER_ID'] || 'aa9f25defa6d4cafb48466df83106065',
|
|
110
76
|
:openstack_region => ENV['OS_REGION_NAME'] || 'RegionOne',
|
|
111
77
|
:openstack_auth_url => "#{@os_auth_url}/auth/tokens")
|
|
112
78
|
|
|
113
79
|
auth_params = {:provider => "openstack",
|
|
114
|
-
:openstack_auth_token =>
|
|
80
|
+
:openstack_auth_token => id_v3.credentials[:openstack_auth_token],
|
|
115
81
|
:openstack_auth_url => "#{@os_auth_url}/auth/tokens",
|
|
116
82
|
:openstack_region => ENV['OS_REGION_NAME'] || 'RegionOne'}
|
|
117
83
|
@fog2 = Fog::Identity::OpenStack::V3.new(auth_params)
|
|
@@ -167,23 +133,23 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
167
133
|
it "find specific user, lists users" do
|
|
168
134
|
VCR.use_cassette('idv3_users') do
|
|
169
135
|
|
|
170
|
-
expect { nonexistent_user = @
|
|
136
|
+
expect { nonexistent_user = @service.users.find_by_id 'u-random-blah' }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
171
137
|
|
|
172
|
-
admin_user = @
|
|
138
|
+
admin_user = @service.users.find_by_name ENV['OS_USERNAME'] || 'admin'
|
|
173
139
|
expect(admin_user.length).to be 1
|
|
174
140
|
|
|
175
|
-
users = @
|
|
141
|
+
users = @service.users
|
|
176
142
|
expect(users).to_not be_nil
|
|
177
143
|
expect(users.length).to_not be 0
|
|
178
144
|
|
|
179
|
-
users_all = @
|
|
145
|
+
users_all = @service.users.all
|
|
180
146
|
expect(users_all).to_not be_nil
|
|
181
147
|
expect(users_all.length).to_not be 0
|
|
182
148
|
|
|
183
|
-
admin_by_id = @
|
|
149
|
+
admin_by_id = @service.users.find_by_id admin_user.first.id
|
|
184
150
|
expect(admin_by_id).to_not be_nil
|
|
185
151
|
|
|
186
|
-
expect(@
|
|
152
|
+
expect(@service.users.find_by_name('pimpernel').length).to be 0
|
|
187
153
|
end
|
|
188
154
|
end
|
|
189
155
|
|
|
@@ -192,44 +158,44 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
192
158
|
|
|
193
159
|
# Make sure there are no existing users called foobar or baz
|
|
194
160
|
['foobar', 'baz'].each do |username|
|
|
195
|
-
user = @
|
|
161
|
+
user = @service.users.find_by_name(username).first
|
|
196
162
|
user.update(:enabled => false) if user
|
|
197
163
|
user.destroy if user
|
|
198
164
|
end
|
|
199
|
-
expect(@
|
|
200
|
-
expect(@
|
|
165
|
+
expect(@service.users.find_by_name('foobar').length).to be 0
|
|
166
|
+
expect(@service.users.find_by_name('baz').length).to be 0
|
|
201
167
|
|
|
202
168
|
# Create a user called foobar
|
|
203
|
-
foobar_user = @
|
|
169
|
+
foobar_user = @service.users.create(:name => 'foobar',
|
|
204
170
|
:email => 'foobar@example.com',
|
|
205
171
|
:password => 's3cret!')
|
|
206
172
|
foobar_id = foobar_user.id
|
|
207
|
-
expect(@
|
|
173
|
+
expect(@service.users.find_by_name('foobar').length).to be 1
|
|
208
174
|
|
|
209
175
|
# Rename it to baz and disable it (required so we can delete it)
|
|
210
176
|
foobar_user.update(:name => 'baz', :enabled => false)
|
|
211
177
|
expect(foobar_user.name).to eq 'baz'
|
|
212
178
|
|
|
213
179
|
# Read the user freshly and check the name & enabled state
|
|
214
|
-
expect(@
|
|
215
|
-
baz_user = @
|
|
180
|
+
expect(@service.users.find_by_name('baz').length).to be 1
|
|
181
|
+
baz_user = @service.users.find_by_id foobar_id
|
|
216
182
|
expect(baz_user).to_not be_nil
|
|
217
183
|
expect(baz_user.name).to eq 'baz'
|
|
218
184
|
expect(baz_user.email).to eq 'foobar@example.com'
|
|
219
185
|
expect(baz_user.enabled).to be false
|
|
220
186
|
|
|
221
187
|
# Try to create the user again
|
|
222
|
-
expect { @
|
|
188
|
+
expect { @service.users.create(:name => 'baz',
|
|
223
189
|
:email => 'foobar@example.com',
|
|
224
190
|
:password => 's3cret!') }.to raise_error(Excon::Errors::Conflict)
|
|
225
191
|
|
|
226
192
|
# Delete the user
|
|
227
193
|
baz_user.destroy
|
|
228
194
|
# Check that the deletion worked
|
|
229
|
-
expect { @
|
|
230
|
-
expect(@
|
|
231
|
-
expect(@
|
|
232
|
-
expect(@
|
|
195
|
+
expect { @service.users.find_by_id foobar_id }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
196
|
+
expect(@service.users.all.select { |user| ['foobar', 'baz'].include? user.name }.length).to be 0
|
|
197
|
+
expect(@service.users.find_by_name('foobar').length).to be 0
|
|
198
|
+
expect(@service.users.find_by_name('baz').length).to be 0
|
|
233
199
|
end
|
|
234
200
|
end
|
|
235
201
|
|
|
@@ -237,35 +203,35 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
237
203
|
VCR.use_cassette('idv3_group_crud_mutation') do
|
|
238
204
|
|
|
239
205
|
# Make sure there are no existing groups called foobar or baz
|
|
240
|
-
@
|
|
206
|
+
@service.groups.all.select { |group| ['foobar', 'baz'].include? group.name }.each do |group|
|
|
241
207
|
group.destroy
|
|
242
208
|
end
|
|
243
|
-
expect(@
|
|
209
|
+
expect(@service.groups.all.select { |group| ['foobar', 'baz'].include? group.name }.length).to be 0
|
|
244
210
|
|
|
245
211
|
# Create a group called foobar
|
|
246
|
-
foobar_group = @
|
|
212
|
+
foobar_group = @service.groups.create(:name => 'foobar', :description => "Group of Foobar users")
|
|
247
213
|
foobar_id = foobar_group.id
|
|
248
|
-
expect(@
|
|
214
|
+
expect(@service.groups.all.select { |group| group.name == 'foobar' }.length).to be 1
|
|
249
215
|
|
|
250
216
|
# Rename it to baz
|
|
251
217
|
foobar_group.update(:name => 'baz', :description => "Group of Baz users")
|
|
252
218
|
expect(foobar_group.name).to eq 'baz'
|
|
253
219
|
|
|
254
220
|
# Read the group freshly and check the name
|
|
255
|
-
expect(@
|
|
256
|
-
baz_group = @
|
|
221
|
+
expect(@service.groups.all.select { |group| group.name == 'baz' }.length).to be 1
|
|
222
|
+
baz_group = @service.groups.find_by_id foobar_id
|
|
257
223
|
expect(baz_group).to_not be_nil
|
|
258
224
|
expect(baz_group.name).to eq 'baz'
|
|
259
225
|
|
|
260
226
|
# Add users to the group
|
|
261
|
-
#foobar_user1 = @
|
|
227
|
+
#foobar_user1 = @service.users.find_by_name('foobar1').first
|
|
262
228
|
#foobar_user1.destroy if foobar_user1
|
|
263
|
-
foobar_user1 = @
|
|
229
|
+
foobar_user1 = @service.users.create(:name => 'foobar1',
|
|
264
230
|
:email => 'foobar1@example.com',
|
|
265
231
|
:password => 's3cret!1')
|
|
266
|
-
#foobar_user2 = @
|
|
232
|
+
#foobar_user2 = @service.users.find_by_name('foobar2').first
|
|
267
233
|
#foobar_user2.destroy if foobar_user2
|
|
268
|
-
foobar_user2 = @
|
|
234
|
+
foobar_user2 = @service.users.create(:name => 'foobar2',
|
|
269
235
|
:email => 'foobar2@example.com',
|
|
270
236
|
:password => 's3cret!2')
|
|
271
237
|
|
|
@@ -297,8 +263,8 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
297
263
|
|
|
298
264
|
# Delete the group
|
|
299
265
|
baz_group.destroy
|
|
300
|
-
expect { @
|
|
301
|
-
expect(@
|
|
266
|
+
expect { @service.groups.find_by_id foobar_id }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
267
|
+
expect(@service.groups.all.select { |group| ['foobar', 'baz'].include? group.name }.length).to be 0
|
|
302
268
|
end
|
|
303
269
|
end
|
|
304
270
|
|
|
@@ -310,16 +276,16 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
310
276
|
:scope => {:project => {:domain => {:name => ENV['OS_USER_DOMAIN_NAME']||'Default'},
|
|
311
277
|
:name => ENV['OS_PROJECT_NAME']||'admin'}}}}
|
|
312
278
|
|
|
313
|
-
token = @
|
|
279
|
+
token = @service.tokens.authenticate(auth)
|
|
314
280
|
expect(token).to_not be_nil
|
|
315
281
|
|
|
316
|
-
validated_token = @
|
|
282
|
+
validated_token = @service.tokens.validate token.value
|
|
317
283
|
expect(validated_token).to_not be_nil
|
|
318
284
|
|
|
319
|
-
@
|
|
320
|
-
@
|
|
285
|
+
@service.tokens.check(token.value)
|
|
286
|
+
@service.tokens.revoke(token.value)
|
|
321
287
|
|
|
322
|
-
expect { @
|
|
288
|
+
expect { @service.tokens.check(token.value) }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
323
289
|
end
|
|
324
290
|
end
|
|
325
291
|
|
|
@@ -330,12 +296,12 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
330
296
|
|
|
331
297
|
begin
|
|
332
298
|
|
|
333
|
-
foobar_user = @
|
|
299
|
+
foobar_user = @service.users.create(:name => 'foobar_385',
|
|
334
300
|
:email => 'foobar_demo@example.com',
|
|
335
301
|
:domain_id => ENV['OS_USER_DOMAIN_ID'] || 'default',
|
|
336
302
|
:password => 's3cret!')
|
|
337
303
|
|
|
338
|
-
foobar_role = @
|
|
304
|
+
foobar_role = @service.roles.create(:name => 'foobar_role390')
|
|
339
305
|
foobar_user.grant_role(foobar_role.id)
|
|
340
306
|
|
|
341
307
|
nonadmin_v3 = Fog::Identity::OpenStack::V3.new(
|
|
@@ -359,9 +325,9 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
359
325
|
:openstack_auth_url => auth_url) }.to raise_error(Excon::Errors::NotFound)
|
|
360
326
|
ensure
|
|
361
327
|
# Clean up
|
|
362
|
-
foobar_user = @
|
|
328
|
+
foobar_user = @service.users.find_by_name('foobar_385').first unless foobar_user
|
|
363
329
|
foobar_user.destroy if foobar_user
|
|
364
|
-
foobar_role = @
|
|
330
|
+
foobar_role = @service.roles.all.select { |role| role.name == 'foobar_role390' }.first unless foobar_role
|
|
365
331
|
foobar_role.destroy if foobar_role
|
|
366
332
|
end
|
|
367
333
|
|
|
@@ -371,18 +337,18 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
371
337
|
it "lists domains" do
|
|
372
338
|
VCR.use_cassette('idv3_domain') do
|
|
373
339
|
|
|
374
|
-
domains = @
|
|
340
|
+
domains = @service.domains
|
|
375
341
|
expect(domains).to_not be_nil
|
|
376
342
|
expect(domains.length).to_not be 0
|
|
377
343
|
|
|
378
|
-
domains_all = @
|
|
344
|
+
domains_all = @service.domains.all
|
|
379
345
|
expect(domains_all).to_not be_nil
|
|
380
346
|
expect(domains_all.length).to_not be 0
|
|
381
347
|
|
|
382
|
-
default_domain = @
|
|
348
|
+
default_domain = @service.domains.find_by_id ENV['OS_USER_DOMAIN_ID']||'default'
|
|
383
349
|
expect(default_domain).to_not be_nil
|
|
384
350
|
|
|
385
|
-
expect { @
|
|
351
|
+
expect { @service.domains.find_by_id 'atlantis' }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
386
352
|
end
|
|
387
353
|
end
|
|
388
354
|
|
|
@@ -391,17 +357,17 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
391
357
|
|
|
392
358
|
begin
|
|
393
359
|
# Create a domain called foobar
|
|
394
|
-
foobar_domain = @
|
|
360
|
+
foobar_domain = @service.domains.create(:name => 'foobar')
|
|
395
361
|
foobar_id = foobar_domain.id
|
|
396
|
-
expect(@
|
|
362
|
+
expect(@service.domains.all(:name => 'foobar').length).to be 1
|
|
397
363
|
|
|
398
364
|
# Rename it to baz and disable it (required so we can delete it)
|
|
399
365
|
foobar_domain.update(:name => 'baz', :enabled => false)
|
|
400
366
|
expect(foobar_domain.name).to eq 'baz'
|
|
401
367
|
|
|
402
368
|
# Read the domain freshly and check the name & enabled state
|
|
403
|
-
expect(@
|
|
404
|
-
baz_domain = @
|
|
369
|
+
expect(@service.domains.all(:name => 'baz').length).to be 1
|
|
370
|
+
baz_domain = @service.domains.find_by_id foobar_id
|
|
405
371
|
expect(baz_domain).to_not be_nil
|
|
406
372
|
expect(baz_domain.name).to eq 'baz'
|
|
407
373
|
expect(baz_domain.enabled).to be false
|
|
@@ -415,9 +381,9 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
415
381
|
rescue
|
|
416
382
|
end
|
|
417
383
|
# Check that the deletion worked
|
|
418
|
-
expect { @
|
|
384
|
+
expect { @service.domains.find_by_id foobar_id }.to raise_error(Fog::Identity::OpenStack::NotFound) if foobar_id
|
|
419
385
|
['foobar', 'baz'].each do |domain_name|
|
|
420
|
-
expect(@
|
|
386
|
+
expect(@service.domains.all(:name => domain_name).length).to be 0
|
|
421
387
|
end
|
|
422
388
|
end
|
|
423
389
|
end
|
|
@@ -428,7 +394,7 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
428
394
|
|
|
429
395
|
VCR.use_cassette('idv3_domain_roles_mutation') do
|
|
430
396
|
begin
|
|
431
|
-
foobar_user = @
|
|
397
|
+
foobar_user = @service.users.create(:name => 'foobar_role_user',
|
|
432
398
|
:email => 'foobar@example.com',
|
|
433
399
|
:password => 's3cret!')
|
|
434
400
|
|
|
@@ -436,18 +402,18 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
436
402
|
expect(foobar_user.roles.length).to be 0
|
|
437
403
|
|
|
438
404
|
# Create a role and add it to the user in the user's domain
|
|
439
|
-
foobar_role = @
|
|
405
|
+
foobar_role = @service.roles.create(:name => 'foobar_role')
|
|
440
406
|
foobar_user.grant_role(foobar_role.id)
|
|
441
407
|
expect(foobar_user.roles.length).to be 1
|
|
442
|
-
assignments = @
|
|
408
|
+
assignments = @service.role_assignments.all(:user_id => foobar_user.id)
|
|
443
409
|
expect(assignments.length).to be 1
|
|
444
410
|
expect(assignments.first.role['id']).to eq foobar_role.id
|
|
445
411
|
expect(assignments.first.user['id']).to eq foobar_user.id
|
|
446
412
|
expect(assignments.first.scope['domain']['id']).to eq foobar_user.domain_id
|
|
447
413
|
expect(assignments.first.links['assignment'].end_with? "/v3/domains/#{foobar_user.domain_id}/users/#{foobar_user.id}/roles/#{foobar_role.id}").to be true
|
|
448
414
|
|
|
449
|
-
# Quick test of @
|
|
450
|
-
all_assignments = @
|
|
415
|
+
# Quick test of @service.role_assignments.all while we're at it
|
|
416
|
+
all_assignments = @service.role_assignments.all
|
|
451
417
|
expect(all_assignments.length).to be >= 1
|
|
452
418
|
|
|
453
419
|
# Check that the user has the role
|
|
@@ -457,9 +423,9 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
457
423
|
foobar_user.revoke_role(foobar_role.id)
|
|
458
424
|
expect(foobar_user.check_role(foobar_role.id)).to be false
|
|
459
425
|
ensure
|
|
460
|
-
foobar_user = @
|
|
426
|
+
foobar_user = @service.users.find_by_name('u-foobar_role_user').first unless foobar_user
|
|
461
427
|
foobar_user.destroy if foobar_user
|
|
462
|
-
foobar_role = @
|
|
428
|
+
foobar_role = @service.roles.all.select { |role| role.name == 'foobar_role' }.first unless foobar_role
|
|
463
429
|
foobar_role.destroy if foobar_role
|
|
464
430
|
end
|
|
465
431
|
|
|
@@ -471,15 +437,15 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
471
437
|
|
|
472
438
|
begin
|
|
473
439
|
# Create a domain called foobar
|
|
474
|
-
foobar_domain = @
|
|
440
|
+
foobar_domain = @service.domains.create(:name => 'd-foobar')
|
|
475
441
|
|
|
476
442
|
# Create a group in this domain
|
|
477
|
-
foobar_group = @
|
|
443
|
+
foobar_group = @service.groups.create(:name => 'g-foobar',
|
|
478
444
|
:description => "Group of Foobar users",
|
|
479
445
|
:domain_id => foobar_domain.id)
|
|
480
446
|
|
|
481
447
|
# Create a user in the domain
|
|
482
|
-
foobar_user = @
|
|
448
|
+
foobar_user = @service.users.create(:name => 'u-foobar_foobar',
|
|
483
449
|
:email => 'foobar@example.com',
|
|
484
450
|
:password => 's3cret!',
|
|
485
451
|
:domain_id => foobar_domain.id)
|
|
@@ -488,19 +454,19 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
488
454
|
expect(foobar_user.roles.length).to be 0
|
|
489
455
|
|
|
490
456
|
# Create a role and add it to the domain group
|
|
491
|
-
foobar_role = @
|
|
457
|
+
foobar_role = @service.roles.all.select { |role| role.name == 'foobar_role' }.first
|
|
492
458
|
foobar_role.destroy if foobar_role
|
|
493
|
-
foobar_role = @
|
|
459
|
+
foobar_role = @service.roles.create(:name => 'foobar_role')
|
|
494
460
|
|
|
495
461
|
foobar_group.grant_role foobar_role.id
|
|
496
462
|
expect(foobar_group.roles.length).to be 1
|
|
497
463
|
|
|
498
464
|
# Add user to the group and check that it inherits the role
|
|
499
465
|
expect(foobar_user.check_role foobar_role.id).to be false
|
|
500
|
-
expect(@
|
|
466
|
+
expect(@service.role_assignments.all(:user_id => foobar_user.id, :effective => true).length).to be 0
|
|
501
467
|
foobar_group.add_user foobar_user.id
|
|
502
468
|
expect(foobar_user.check_role foobar_role.id).to be false # Still false in absolute assignment terms
|
|
503
|
-
assignments = @
|
|
469
|
+
assignments = @service.role_assignments.all(:user_id => foobar_user.id, :effective => true)
|
|
504
470
|
expect(assignments.length).to be 1
|
|
505
471
|
expect(assignments.first.role['id']).to eq foobar_role.id
|
|
506
472
|
expect(assignments.first.user['id']).to eq foobar_user.id
|
|
@@ -508,7 +474,7 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
508
474
|
expect(assignments.first.links['assignment'].end_with? "/v3/domains/#{foobar_domain.id}/groups/#{foobar_group.id}/roles/#{foobar_role.id}").to be true
|
|
509
475
|
expect(assignments.first.links['membership'].end_with? "/v3/groups/#{foobar_group.id}/users/#{foobar_user.id}").to be true
|
|
510
476
|
|
|
511
|
-
group_assignments = @
|
|
477
|
+
group_assignments = @service.role_assignments.all(:group_id => foobar_group.id)
|
|
512
478
|
expect(group_assignments.length).to be 1
|
|
513
479
|
expect(group_assignments.first.role['id']).to eq foobar_role.id
|
|
514
480
|
expect(group_assignments.first.group['id']).to eq foobar_group.id
|
|
@@ -517,16 +483,16 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
517
483
|
|
|
518
484
|
# Revoke the role from the group and check the user no longer has it
|
|
519
485
|
foobar_group.revoke_role foobar_role.id
|
|
520
|
-
expect(@
|
|
486
|
+
expect(@service.role_assignments.all(:user_id => foobar_user.id, :effective => true).length).to be 0
|
|
521
487
|
ensure
|
|
522
488
|
# Clean up
|
|
523
|
-
foobar_user = @
|
|
489
|
+
foobar_user = @service.users.find_by_name('u-foobar_foobar').first unless foobar_user
|
|
524
490
|
foobar_user.destroy if foobar_user
|
|
525
|
-
foobar_group = @
|
|
491
|
+
foobar_group = @service.groups.all.select { |group| group.name == 'g-foobar' }.first unless foobar_group
|
|
526
492
|
foobar_group.destroy if foobar_group
|
|
527
|
-
foobar_role = @
|
|
493
|
+
foobar_role = @service.roles.all.select { |role| role.name == 'foobar_role' }.first unless foobar_role
|
|
528
494
|
foobar_role.destroy if foobar_role
|
|
529
|
-
foobar_domain = @
|
|
495
|
+
foobar_domain = @service.domains.all.select { |domain| domain.name == 'd-foobar' }.first unless foobar_domain
|
|
530
496
|
foobar_domain.update(:enabled => false) if foobar_domain
|
|
531
497
|
foobar_domain.destroy if foobar_domain
|
|
532
498
|
end
|
|
@@ -536,18 +502,18 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
536
502
|
it "lists roles" do
|
|
537
503
|
VCR.use_cassette('idv3_role') do
|
|
538
504
|
|
|
539
|
-
roles = @
|
|
505
|
+
roles = @service.roles
|
|
540
506
|
expect(roles).to_not be_nil
|
|
541
507
|
expect(roles.length).to_not be 0
|
|
542
508
|
|
|
543
|
-
roles_all = @
|
|
509
|
+
roles_all = @service.roles.all
|
|
544
510
|
expect(roles_all).to_not be_nil
|
|
545
511
|
expect(roles_all.length).to_not be 0
|
|
546
512
|
|
|
547
|
-
role_by_id = @
|
|
513
|
+
role_by_id = @service.roles.find_by_id roles_all.first.id
|
|
548
514
|
expect(role_by_id).to_not be_nil
|
|
549
515
|
|
|
550
|
-
expect { @
|
|
516
|
+
expect { @service.roles.find_by_id 'atlantis' }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
551
517
|
end
|
|
552
518
|
end
|
|
553
519
|
|
|
@@ -556,26 +522,26 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
556
522
|
|
|
557
523
|
begin
|
|
558
524
|
# Create a role called foobar
|
|
559
|
-
foobar_role = @
|
|
525
|
+
foobar_role = @service.roles.create(:name => 'foobar23')
|
|
560
526
|
foobar_id = foobar_role.id
|
|
561
|
-
expect(@
|
|
527
|
+
expect(@service.roles.all(:name => 'foobar23').length).to be 1
|
|
562
528
|
|
|
563
529
|
# Rename it to baz
|
|
564
530
|
foobar_role.update(:name => 'baz23')
|
|
565
531
|
expect(foobar_role.name).to eq 'baz23'
|
|
566
532
|
|
|
567
533
|
# Read the role freshly and check the name & enabled state
|
|
568
|
-
expect(@
|
|
569
|
-
baz_role = @
|
|
534
|
+
expect(@service.roles.all(:name => 'baz23').length).to be 1
|
|
535
|
+
baz_role = @service.roles.find_by_id foobar_id
|
|
570
536
|
expect(baz_role).to_not be_nil
|
|
571
537
|
expect(baz_role.name).to eq 'baz23'
|
|
572
538
|
ensure
|
|
573
539
|
# Delete the role
|
|
574
540
|
baz_role.destroy if baz_role
|
|
575
541
|
# Check that the deletion worked
|
|
576
|
-
expect { @
|
|
542
|
+
expect { @service.roles.find_by_id foobar_id }.to raise_error(Fog::Identity::OpenStack::NotFound) if foobar_id
|
|
577
543
|
['foobar23', 'baz23'].each do |role_name|
|
|
578
|
-
expect(@
|
|
544
|
+
expect(@service.roles.all(:name => role_name).length).to be 0
|
|
579
545
|
end
|
|
580
546
|
end
|
|
581
547
|
end
|
|
@@ -584,30 +550,30 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
584
550
|
it "lists projects" do
|
|
585
551
|
VCR.use_cassette('idv3_project') do
|
|
586
552
|
|
|
587
|
-
projects = @
|
|
553
|
+
projects = @service.projects
|
|
588
554
|
expect(projects).to_not be_nil
|
|
589
555
|
expect(projects.length).to_not be 0
|
|
590
556
|
|
|
591
|
-
projects_all = @
|
|
557
|
+
projects_all = @service.projects.all
|
|
592
558
|
expect(projects_all).to_not be_nil
|
|
593
559
|
expect(projects_all.length).to_not be 0
|
|
594
|
-
project_byid = @
|
|
560
|
+
project_byid = @service.projects.find_by_id projects_all.first.id
|
|
595
561
|
expect(project_byid).to_not be_nil
|
|
596
562
|
|
|
597
|
-
expect { @
|
|
563
|
+
expect { @service.projects.find_by_id 'atlantis' }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
598
564
|
end
|
|
599
565
|
end
|
|
600
566
|
|
|
601
567
|
it "CRUD projects" do
|
|
602
568
|
VCR.use_cassette('idv3_project_crud') do
|
|
603
569
|
|
|
604
|
-
default_domain = @
|
|
570
|
+
default_domain = @service.domains.find_by_id ENV['OS_USER_DOMAIN_ID']||'default'
|
|
605
571
|
|
|
606
572
|
begin
|
|
607
573
|
# Create a project called foobar - should not work without domain id?
|
|
608
|
-
foobar_project = @
|
|
574
|
+
foobar_project = @service.projects.create(:name => 'p-foobar46')
|
|
609
575
|
foobar_id = foobar_project.id
|
|
610
|
-
expect(@
|
|
576
|
+
expect(@service.projects.all(:name => 'p-foobar46').length).to be 1
|
|
611
577
|
expect(foobar_project.domain_id).to eq default_domain.id
|
|
612
578
|
|
|
613
579
|
# Rename it to baz and disable it (required so we can delete it)
|
|
@@ -615,8 +581,8 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
615
581
|
expect(foobar_project.name).to eq 'p-baz46'
|
|
616
582
|
|
|
617
583
|
# Read the project freshly and check the name & enabled state
|
|
618
|
-
expect(@
|
|
619
|
-
baz_project = @
|
|
584
|
+
expect(@service.projects.all(:name => 'p-baz46').length).to be 1
|
|
585
|
+
baz_project = @service.projects.find_by_id foobar_id
|
|
620
586
|
expect(baz_project).to_not be_nil
|
|
621
587
|
expect(baz_project.name).to eq 'p-baz46'
|
|
622
588
|
expect(baz_project.enabled).to be false
|
|
@@ -625,9 +591,102 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
625
591
|
baz_project.destroy
|
|
626
592
|
|
|
627
593
|
# Check that the deletion worked
|
|
628
|
-
expect { @
|
|
594
|
+
expect { @service.projects.find_by_id foobar_id }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
629
595
|
['p-foobar46', 'p-baz46'].each do |project_name|
|
|
630
|
-
expect(@
|
|
596
|
+
expect(@service.projects.all(:name => project_name).length).to be 0
|
|
597
|
+
end
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
it "CRUD & list hierarchical projects" do
|
|
603
|
+
VCR.use_cassette('idv3_project_hier_crud_list') do
|
|
604
|
+
|
|
605
|
+
default_domain = @service.domains.find_by_id ENV['OS_USER_DOMAIN_ID']||'default'
|
|
606
|
+
|
|
607
|
+
begin
|
|
608
|
+
# Create a project called foobar
|
|
609
|
+
foobar_project = @service.projects.create(:name => 'p-foobar67')
|
|
610
|
+
foobar_id = foobar_project.id
|
|
611
|
+
|
|
612
|
+
# Create a sub-project called baz
|
|
613
|
+
baz_project = @service.projects.create(:name => 'p-baz67', :parent_id => foobar_id)
|
|
614
|
+
baz_id = baz_project.id
|
|
615
|
+
|
|
616
|
+
expect(baz_project.parent_id).to eq foobar_id
|
|
617
|
+
|
|
618
|
+
# Read the project freshly and check the parent_id
|
|
619
|
+
fresh_baz_project = @service.projects.all(:name => 'p-baz67').first
|
|
620
|
+
expect(fresh_baz_project).to_not be_nil
|
|
621
|
+
expect(fresh_baz_project.parent_id).to eq foobar_id
|
|
622
|
+
|
|
623
|
+
# Create another sub-project called boo
|
|
624
|
+
boo_project = @service.projects.create(:name => 'p-boo67', :parent_id => foobar_id)
|
|
625
|
+
boo_id = boo_project.id
|
|
626
|
+
|
|
627
|
+
# Create a sub-project of boo called booboo
|
|
628
|
+
booboo_project = @service.projects.create(:name => 'p-booboo67', :parent_id => boo_id)
|
|
629
|
+
booboo_id = booboo_project.id
|
|
630
|
+
|
|
631
|
+
# Make sure we have a role on all these projects (needed for subtree_as_list and parents_as_list)
|
|
632
|
+
prj_role = @service.roles.create(:name => 'r-project67')
|
|
633
|
+
[foobar_project, baz_project, boo_project, booboo_project].each do |project|
|
|
634
|
+
project.grant_role_to_user(prj_role.id, @service.current_user_id)
|
|
635
|
+
end
|
|
636
|
+
|
|
637
|
+
# Get the children of foobar, as a tree of IDs
|
|
638
|
+
foobar_kids = @service.projects.find_by_id(foobar_id, :subtree_as_ids).subtree
|
|
639
|
+
expect(foobar_kids.keys.length).to eq 2
|
|
640
|
+
|
|
641
|
+
boo_index = foobar_kids.keys.index boo_id
|
|
642
|
+
expect(boo_index).to_not be_nil
|
|
643
|
+
|
|
644
|
+
foobar_child_id = foobar_kids.keys[boo_index]
|
|
645
|
+
expect(foobar_kids[foobar_child_id].length).to eq 1
|
|
646
|
+
foobar_grandchild_id = foobar_kids[foobar_child_id].keys.first
|
|
647
|
+
expect(foobar_grandchild_id).to eq booboo_id
|
|
648
|
+
|
|
649
|
+
# Get the children of foobar, as a list of objects
|
|
650
|
+
foobar_kids = @service.projects.find_by_id(foobar_id, :subtree_as_list).subtree
|
|
651
|
+
expect(foobar_kids.length).to eq 3
|
|
652
|
+
expect([foobar_kids[0].id,foobar_kids[1].id,foobar_kids[2].id].sort
|
|
653
|
+
).to eq [baz_id, boo_id, booboo_id].sort
|
|
654
|
+
|
|
655
|
+
# Create a another sub-project of boo called fooboo and check that it appears in the parent's subtree
|
|
656
|
+
fooboo_project = @service.projects.create(:name => 'p-fooboo67', :parent_id => boo_id)
|
|
657
|
+
fooboo_id = fooboo_project.id
|
|
658
|
+
fooboo_project.grant_role_to_user(prj_role.id, @service.current_user_id)
|
|
659
|
+
foobar_new_kids = @service.projects.find_by_id(foobar_id, :subtree_as_list).subtree
|
|
660
|
+
expect(foobar_new_kids.length).to eq 4
|
|
661
|
+
|
|
662
|
+
# Get the parents of booboo, as a tree of IDs
|
|
663
|
+
booboo_parents = @service.projects.find_by_id(booboo_id, :parents_as_ids).parents
|
|
664
|
+
expect(booboo_parents.keys.length).to eq 1
|
|
665
|
+
booboo_parent_id = booboo_parents.keys.first
|
|
666
|
+
expect(booboo_parents[booboo_parent_id].length).to eq 1
|
|
667
|
+
booboo_grandparent_id = booboo_parents[booboo_parent_id].keys.first
|
|
668
|
+
expect(booboo_grandparent_id).to eq foobar_id
|
|
669
|
+
expect(booboo_parents[booboo_parent_id][booboo_grandparent_id]).to be_nil
|
|
670
|
+
|
|
671
|
+
# Get the parents of booboo, as a list of objects
|
|
672
|
+
booboo_parents = @service.projects.find_by_id(booboo_id, :parents_as_list).parents
|
|
673
|
+
expect(booboo_parents.length).to eq 2
|
|
674
|
+
expect([booboo_parents[0].id,booboo_parents[1].id].sort).to eq [foobar_id, boo_id].sort
|
|
675
|
+
ensure
|
|
676
|
+
# Delete the projects
|
|
677
|
+
fooboo_project.destroy if fooboo_project
|
|
678
|
+
booboo_project.destroy if booboo_project
|
|
679
|
+
boo_project.destroy if boo_project
|
|
680
|
+
baz_project.destroy if baz_project
|
|
681
|
+
foobar_project.destroy if foobar_project
|
|
682
|
+
prj_role = @service.roles.all(:name => 'r-project67').first unless prj_role
|
|
683
|
+
prj_role.destroy if prj_role
|
|
684
|
+
# Check that the deletion worked
|
|
685
|
+
expect { @service.projects.find_by_id foobar_id }.to raise_error(Fog::Identity::OpenStack::NotFound) if foobar_id
|
|
686
|
+
['p-booboo67', 'p-fooboo67', 'p-boo67', 'p-baz67', 'p-foobar67'].each do |project_name|
|
|
687
|
+
prj = @service.projects.all(:name => project_name).first
|
|
688
|
+
prj.destroy if prj
|
|
689
|
+
expect(@service.projects.all(:name => project_name).length).to be 0
|
|
631
690
|
end
|
|
632
691
|
end
|
|
633
692
|
end
|
|
@@ -637,35 +696,35 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
637
696
|
VCR.use_cassette('idv3_project_group_user_roles_mutation') do
|
|
638
697
|
|
|
639
698
|
# Make sure there is no existing project called foobar
|
|
640
|
-
@
|
|
699
|
+
@service.projects.all(:name => 'p-foobar69').each do |project|
|
|
641
700
|
project.update(:enabled => false)
|
|
642
701
|
project.destroy
|
|
643
702
|
end
|
|
644
|
-
expect(@
|
|
703
|
+
expect(@service.projects.all(:name => 'p-foobar69').length).to be 0
|
|
645
704
|
|
|
646
705
|
begin
|
|
647
706
|
# Create a project called foobar
|
|
648
|
-
foobar_project = @
|
|
707
|
+
foobar_project = @service.projects.create(:name => 'p-foobar69')
|
|
649
708
|
# Create a role called baz
|
|
650
|
-
@
|
|
709
|
+
@service.roles.all(:name => 'baz').each do |role|
|
|
651
710
|
role.update(:enabled => false)
|
|
652
711
|
role.destroy
|
|
653
712
|
end
|
|
654
|
-
baz_role = @
|
|
713
|
+
baz_role = @service.roles.create(:name => 'baz69')
|
|
655
714
|
|
|
656
715
|
# Create a user
|
|
657
|
-
foobar_user = @
|
|
716
|
+
foobar_user = @service.users.create(:name => 'u-foobar69',
|
|
658
717
|
:email => 'foobar@example.com',
|
|
659
718
|
:password => 's3cret!')
|
|
660
719
|
|
|
661
720
|
# Create a group and add the user to it
|
|
662
|
-
foobar_group = @
|
|
721
|
+
foobar_group = @service.groups.create(:name => 'g-foobar69',
|
|
663
722
|
:description => "Group of Foobar users")
|
|
664
723
|
foobar_group.add_user foobar_user.id
|
|
665
724
|
|
|
666
725
|
# User has no projects initially
|
|
667
726
|
expect(foobar_user.projects.length).to be 0
|
|
668
|
-
expect(@
|
|
727
|
+
expect(@service.role_assignments.all(:user_id => foobar_user.id,
|
|
669
728
|
:project_id => foobar_project.id,
|
|
670
729
|
:effective => true).length).to be 0
|
|
671
730
|
expect(foobar_project.user_roles(foobar_user.id).length).to be 0
|
|
@@ -684,7 +743,7 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
684
743
|
# Group initially has no roles in project
|
|
685
744
|
expect(foobar_project.group_roles(foobar_group.id).length).to be 0
|
|
686
745
|
|
|
687
|
-
expect(@
|
|
746
|
+
expect(@service.role_assignments.all(:user_id => foobar_user.id,
|
|
688
747
|
:project_id => foobar_project.id,
|
|
689
748
|
:effective => true).length).to be 0
|
|
690
749
|
|
|
@@ -694,7 +753,7 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
694
753
|
expect(foobar_project.group_roles(foobar_group.id).length).to be 1
|
|
695
754
|
|
|
696
755
|
# Now we check that a user has the role in that project
|
|
697
|
-
assignments = @
|
|
756
|
+
assignments = @service.role_assignments.all(:user_id => foobar_user.id,
|
|
698
757
|
:project_id => foobar_project.id,
|
|
699
758
|
:effective => true)
|
|
700
759
|
expect(assignments.length).to be 1
|
|
@@ -726,39 +785,39 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
726
785
|
it "lists services" do
|
|
727
786
|
VCR.use_cassette('idv3_service') do
|
|
728
787
|
|
|
729
|
-
services = @
|
|
788
|
+
services = @service.services
|
|
730
789
|
expect(services).to_not be_nil
|
|
731
790
|
expect(services.length).to_not be 0
|
|
732
791
|
|
|
733
|
-
services_all = @
|
|
792
|
+
services_all = @service.services.all
|
|
734
793
|
expect(services_all).to_not be_nil
|
|
735
794
|
expect(services_all.length).to_not be 0
|
|
736
795
|
|
|
737
|
-
some_service = @
|
|
796
|
+
some_service = @service.services.find_by_id services_all.first.id
|
|
738
797
|
expect(some_service).to_not be_nil
|
|
739
798
|
|
|
740
|
-
expect { @
|
|
799
|
+
expect { @service.services.find_by_id 'atlantis' }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
741
800
|
end
|
|
742
801
|
end
|
|
743
802
|
|
|
744
803
|
it "CRUD services" do
|
|
745
804
|
VCR.use_cassette('idv3_services_crud') do
|
|
746
805
|
|
|
747
|
-
all_services = @
|
|
806
|
+
all_services = @service.services.all
|
|
748
807
|
|
|
749
808
|
begin
|
|
750
809
|
# Create a service called foobar
|
|
751
|
-
foobar_service = @
|
|
810
|
+
foobar_service = @service.services.create(:type => 'volume', :name => 'foobar')
|
|
752
811
|
foobar_id = foobar_service.id
|
|
753
|
-
expect(@
|
|
812
|
+
expect(@service.services.all(:type => 'volume').select { |service| service.name == 'foobar' }.length).to be 1
|
|
754
813
|
|
|
755
814
|
# Rename it to baz
|
|
756
815
|
foobar_service.update(:name => 'baz')
|
|
757
816
|
expect(foobar_service.name).to eq 'baz'
|
|
758
817
|
|
|
759
818
|
# Read the service freshly and check the name
|
|
760
|
-
expect(@
|
|
761
|
-
baz_service = @
|
|
819
|
+
expect(@service.services.all.select { |service| service.name == 'baz' }.length).to be 1
|
|
820
|
+
baz_service = @service.services.find_by_id foobar_id
|
|
762
821
|
expect(baz_service).to_not be_nil
|
|
763
822
|
expect(baz_service.name).to eq 'baz'
|
|
764
823
|
expect(baz_service.type).to eq 'volume'
|
|
@@ -767,8 +826,8 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
767
826
|
baz_service.destroy if baz_service
|
|
768
827
|
|
|
769
828
|
# Check that the deletion worked
|
|
770
|
-
expect { @
|
|
771
|
-
expect(@
|
|
829
|
+
expect { @service.services.find_by_id foobar_id }.to raise_error(Fog::Identity::OpenStack::NotFound) if foobar_id
|
|
830
|
+
expect(@service.services.all.select { |service| ['foobar', 'baz'].include? service.name }.length).to be 0
|
|
772
831
|
end
|
|
773
832
|
end
|
|
774
833
|
end
|
|
@@ -776,36 +835,36 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
776
835
|
it "lists endpoints" do
|
|
777
836
|
VCR.use_cassette('idv3_endpoint') do
|
|
778
837
|
|
|
779
|
-
endpoints = @
|
|
838
|
+
endpoints = @service.endpoints
|
|
780
839
|
expect(endpoints).to_not be_nil
|
|
781
840
|
expect(endpoints.length).to_not be 0
|
|
782
841
|
|
|
783
|
-
endpoints_all = @
|
|
842
|
+
endpoints_all = @service.endpoints.all
|
|
784
843
|
expect(endpoints_all).to_not be_nil
|
|
785
844
|
expect(endpoints_all.length).to_not be 0
|
|
786
845
|
|
|
787
|
-
some_endpoint = @
|
|
846
|
+
some_endpoint = @service.endpoints.find_by_id endpoints_all.first.id
|
|
788
847
|
expect(some_endpoint).to_not be_nil
|
|
789
848
|
|
|
790
|
-
expect { @
|
|
849
|
+
expect { @service.endpoints.find_by_id 'atlantis' }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
791
850
|
end
|
|
792
851
|
end
|
|
793
852
|
|
|
794
853
|
it "CRUD endpoints" do
|
|
795
854
|
VCR.use_cassette('idv3_endpoints_crud') do
|
|
796
855
|
|
|
797
|
-
service = @
|
|
798
|
-
all_endpoints = @
|
|
856
|
+
service = @service.services.all.first
|
|
857
|
+
all_endpoints = @service.endpoints.all
|
|
799
858
|
|
|
800
859
|
begin
|
|
801
860
|
# Create a endpoint called foobar
|
|
802
|
-
foobar_endpoint = @
|
|
861
|
+
foobar_endpoint = @service.endpoints.create(:service_id => service.id,
|
|
803
862
|
:interface => 'internal',
|
|
804
863
|
:name => 'foobar',
|
|
805
864
|
:url => 'http://example.com/foobar',
|
|
806
865
|
:enabled => false)
|
|
807
866
|
foobar_id = foobar_endpoint.id
|
|
808
|
-
expect(@
|
|
867
|
+
expect(@service.endpoints.all(:interface => 'internal').select { |endpoint| endpoint.name == 'foobar' }.length).to be 1
|
|
809
868
|
|
|
810
869
|
# Rename it to baz
|
|
811
870
|
foobar_endpoint.update(:name => 'baz', :url => 'http://example.com/baz')
|
|
@@ -813,8 +872,8 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
813
872
|
expect(foobar_endpoint.url).to eq 'http://example.com/baz'
|
|
814
873
|
|
|
815
874
|
# Read the endpoint freshly and check the name
|
|
816
|
-
expect(@
|
|
817
|
-
baz_endpoint = @
|
|
875
|
+
expect(@service.endpoints.all(:interface => 'internal').select { |endpoint| endpoint.name == 'baz' }.length).to be 1
|
|
876
|
+
baz_endpoint = @service.endpoints.find_by_id foobar_id
|
|
818
877
|
expect(baz_endpoint).to_not be_nil
|
|
819
878
|
expect(baz_endpoint.name).to eq 'baz'
|
|
820
879
|
expect(baz_endpoint.url).to eq 'http://example.com/baz'
|
|
@@ -824,21 +883,21 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
824
883
|
baz_endpoint.destroy
|
|
825
884
|
|
|
826
885
|
# Check that the deletion worked
|
|
827
|
-
expect { @
|
|
828
|
-
expect(@
|
|
886
|
+
expect { @service.endpoints.find_by_id foobar_id }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
887
|
+
expect(@service.endpoints.all.select { |endpoint| ['foobar', 'baz'].include? endpoint.name }.length).to be 0
|
|
829
888
|
end
|
|
830
889
|
end
|
|
831
890
|
end
|
|
832
891
|
|
|
833
892
|
it "lists OS credentials" do
|
|
834
893
|
VCR.use_cassette('idv3_credential') do
|
|
835
|
-
credentials = @
|
|
894
|
+
credentials = @service.os_credentials
|
|
836
895
|
expect(credentials).to_not be_nil
|
|
837
896
|
|
|
838
|
-
credentials_all = @
|
|
897
|
+
credentials_all = @service.os_credentials.all
|
|
839
898
|
expect(credentials_all).to_not be_nil
|
|
840
899
|
|
|
841
|
-
expect { @
|
|
900
|
+
expect { @service.os_credentials.find_by_id 'atlantis' }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
842
901
|
end
|
|
843
902
|
end
|
|
844
903
|
|
|
@@ -847,10 +906,10 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
847
906
|
|
|
848
907
|
begin
|
|
849
908
|
# Create a user
|
|
850
|
-
foobar_user = @
|
|
909
|
+
foobar_user = @service.users.create(:name => 'u-foobar_cred',
|
|
851
910
|
:email => 'foobar@example.com',
|
|
852
911
|
:password => 's3cret!')
|
|
853
|
-
project = @
|
|
912
|
+
project = @service.projects.all.first
|
|
854
913
|
|
|
855
914
|
access_key = '9c4e774a-f644-498f-90c4-970b3f817fc5'
|
|
856
915
|
secret_key = '7e084117-b13d-4656-9eca-85376b690897'
|
|
@@ -860,18 +919,18 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
860
919
|
:secret => secret_key}.to_json
|
|
861
920
|
|
|
862
921
|
# Make sure there are no existing ec2 credentials
|
|
863
|
-
@
|
|
922
|
+
@service.os_credentials.all.select { |credential| credential.type == 'foo' || credential.type == 'ec2' }.each do |credential|
|
|
864
923
|
credential.destroy
|
|
865
924
|
end
|
|
866
|
-
expect(@
|
|
925
|
+
expect(@service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length).to be 0
|
|
867
926
|
|
|
868
927
|
# Create a credential
|
|
869
|
-
foo_credential = @
|
|
928
|
+
foo_credential = @service.os_credentials.create(:type => 'ec2',
|
|
870
929
|
:project_id => project.id,
|
|
871
930
|
:user_id => foobar_user.id,
|
|
872
931
|
:blob => blob_json)
|
|
873
932
|
credential_id = foo_credential.id
|
|
874
|
-
expect(@
|
|
933
|
+
expect(@service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length).to be 1
|
|
875
934
|
|
|
876
935
|
# Update secret key
|
|
877
936
|
new_secret_key = '62307bcd-ca3c-47ae-a114-27a6cadb5bc9'
|
|
@@ -881,14 +940,14 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
881
940
|
expect(JSON.parse(foo_credential.blob)['secret']).to eq new_secret_key
|
|
882
941
|
|
|
883
942
|
# Read the credential freshly and check the secret key
|
|
884
|
-
expect(@
|
|
885
|
-
updated_credential = @
|
|
943
|
+
expect(@service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length).to be 1
|
|
944
|
+
updated_credential = @service.os_credentials.find_by_id credential_id
|
|
886
945
|
expect(updated_credential).to_not be_nil
|
|
887
946
|
expect(updated_credential.type).to eq 'ec2'
|
|
888
947
|
expect(JSON.parse(updated_credential.blob)['secret']).to eq new_secret_key
|
|
889
948
|
|
|
890
949
|
ensure
|
|
891
|
-
foobar_user = @
|
|
950
|
+
foobar_user = @service.users.find_by_name('u-foobar_cred').first unless foobar_user
|
|
892
951
|
foobar_user.destroy if foobar_user
|
|
893
952
|
# Delete the credential
|
|
894
953
|
begin
|
|
@@ -899,23 +958,23 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
899
958
|
end
|
|
900
959
|
|
|
901
960
|
# Check that the deletion worked
|
|
902
|
-
expect { @
|
|
903
|
-
expect(@
|
|
961
|
+
expect { @service.os_credentials.find_by_id credential_id }.to raise_error(Fog::Identity::OpenStack::NotFound) if credential_id
|
|
962
|
+
expect(@service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length).to be 0
|
|
904
963
|
end
|
|
905
964
|
end
|
|
906
965
|
end
|
|
907
966
|
|
|
908
967
|
it "lists policies" do
|
|
909
968
|
VCR.use_cassette('idv3_policy') do
|
|
910
|
-
policies = @
|
|
969
|
+
policies = @service.policies
|
|
911
970
|
expect(policies).to_not be_nil
|
|
912
971
|
expect(policies.length).to be 0
|
|
913
972
|
|
|
914
|
-
policies_all = @
|
|
973
|
+
policies_all = @service.policies.all
|
|
915
974
|
expect(policies_all).to_not be_nil
|
|
916
975
|
expect(policies_all.length).to be 0
|
|
917
976
|
|
|
918
|
-
expect { @
|
|
977
|
+
expect { @service.policies.find_by_id 'atlantis' }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
919
978
|
end
|
|
920
979
|
end
|
|
921
980
|
|
|
@@ -925,13 +984,13 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
925
984
|
blob = {'foobar_user' => ['role:compute-user']}.to_json
|
|
926
985
|
|
|
927
986
|
# Make sure there are no existing policies
|
|
928
|
-
expect(@
|
|
987
|
+
expect(@service.policies.all.select { |policy| policy.type == 'application/json' }.length).to be 0
|
|
929
988
|
|
|
930
989
|
# Create a policy
|
|
931
|
-
foo_policy = @
|
|
990
|
+
foo_policy = @service.policies.create(:type => 'application/json',
|
|
932
991
|
:blob => blob)
|
|
933
992
|
policy_id = foo_policy.id
|
|
934
|
-
expect(@
|
|
993
|
+
expect(@service.policies.all.select { |policy| policy.type == 'application/json' }.length).to be 1
|
|
935
994
|
|
|
936
995
|
# Update policy blob
|
|
937
996
|
new_blob = {'baz_user' => ['role:compute-user']}.to_json
|
|
@@ -939,8 +998,8 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
939
998
|
expect(foo_policy.blob).to eq new_blob
|
|
940
999
|
|
|
941
1000
|
# Read the policy freshly and check the secret key
|
|
942
|
-
expect(@
|
|
943
|
-
updated_policy = @
|
|
1001
|
+
expect(@service.policies.all.select { |policy| policy.type == 'application/json' }.length).to be 1
|
|
1002
|
+
updated_policy = @service.policies.find_by_id policy_id
|
|
944
1003
|
expect(updated_policy).to_not be_nil
|
|
945
1004
|
expect(updated_policy.type).to eq 'application/json'
|
|
946
1005
|
expect(updated_policy.blob).to eq new_blob
|
|
@@ -949,8 +1008,8 @@ RSpec.describe Fog::Identity::OpenStack::V3 do
|
|
|
949
1008
|
updated_policy.destroy
|
|
950
1009
|
|
|
951
1010
|
# Check that the deletion worked
|
|
952
|
-
expect { @
|
|
953
|
-
expect(@
|
|
1011
|
+
expect { @service.policies.find_by_id policy_id }.to raise_error(Fog::Identity::OpenStack::NotFound)
|
|
1012
|
+
expect(@service.policies.all.select { |policy| policy.type == 'application/json' }.length).to be 0
|
|
954
1013
|
end
|
|
955
1014
|
end
|
|
956
1015
|
|