Skip to content

Commit bb3385d

Browse files
committed
case for expired license.
Signed-off-by: talktovikas <[email protected]> making it 403 Signed-off-by: talktovikas <[email protected]> running cases only for automate. Signed-off-by: talktovikas <[email protected]> test for chef-zero Signed-off-by: talktovikas <[email protected]> test for /users Signed-off-by: talktovikas <[email protected]> adding env in docker Signed-off-by: talktovikas <[email protected]> fixing verify syntax. Signed-off-by: talktovikas <[email protected]> fixing placement of env variables. Signed-off-by: talktovikas <[email protected]> fixing placement of executor. Signed-off-by: talktovikas <[email protected]> test Signed-off-by: talktovikas <[email protected]>
1 parent f76eafe commit bb3385d

File tree

2 files changed

+86
-11
lines changed

2 files changed

+86
-11
lines changed

.expeditor/verify.pipeline.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ steps:
154154
- USE_OMNIBUS_FILES=0
155155
- PEDANT_OPTS="--skip-oc_id"
156156
- BUNDLE_GEMFILE=/workdir/oc-chef-pedant/Gemfile
157+
- IS_AUTOMATE=false
157158

158159
- label: With ChefFS=1
159160
command:
@@ -174,6 +175,7 @@ steps:
174175
- PEDANT_OPTS="--skip-oc_id"
175176
- CHEF_FS=1
176177
- BUNDLE_GEMFILE=/workdir/oc-chef-pedant/Gemfile
178+
- IS_AUTOMATE=false
177179

178180
- label: automate_build
179181
command:
@@ -216,37 +218,44 @@ steps:
216218
- .expeditor/chef_server.sh
217219
timeout_in_minutes: 30 # longer timeout for chef-server
218220
expeditor:
219-
executor:
220-
linux:
221-
privileged: true
222221
secrets:
223222
A2_LICENSE:
224223
path: secret/a2/license
225224
field: license
225+
executor:
226+
linux:
227+
privileged: true
228+
environment:
229+
- IS_AUTOMATE=true
226230

227231
- label: "chef server only"
228232
command:
229233
- .expeditor/chef_server_only.sh
230234
timeout_in_minutes: 20
231235
expeditor:
232-
executor:
233-
linux:
234-
privileged: true
235236
secrets:
236237
A2_LICENSE:
237238
path: secret/a2/license
238239
field: license
240+
executor:
241+
linux:
242+
privileged: true
243+
environment:
244+
- IS_AUTOMATE=true
245+
239246

240247
- label: "ha chef server"
241248
command:
242249
- .expeditor/ha_chef_server.sh
243250
timeout_in_minutes: 35
244251
expeditor:
245-
executor:
246-
linux:
247-
single-use: true
248-
privileged: true
249252
secrets:
250253
A2_LICENSE:
251254
path: secret/a2/license
252-
field: license
255+
field: license
256+
executor:
257+
linux:
258+
privileged: true
259+
single-use: true
260+
environment:
261+
- IS_AUTOMATE=true
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# -*- coding: utf-8 -*-
2+
require 'pedant/rspec/common'
3+
4+
describe "server license testing", :license do
5+
6+
# Pedant has configurable test users.
7+
# Selects Pedant users that are marked as associated
8+
let(:default_pedant_user_names) { platform.users.select(&:associate).map(&:name).sort }
9+
let(:default_users_body) { default_pedant_user_names.map { |user| {"user" => {"username" => user} } } }
10+
11+
# context "/users endpoint", automate: true do
12+
context "/users endpoint" do
13+
let(:request_url) { "#{platform.server}/users" }
14+
let(:status_url) { "#{platform.server}/_status" }
15+
16+
let(:users_body) do
17+
{
18+
# There are other users, but these are ours, so they should always be
19+
# somewhere in the userspace soup.
20+
"pivotal" => "#{request_url}/pivotal",
21+
platform.bad_user.name => "#{request_url}/#{platform.bad_user.name}",
22+
platform.admin_user.name => "#{request_url}/#{platform.admin_user.name}",
23+
platform.non_admin_user.name => "#{request_url}/#{platform.non_admin_user.name}",
24+
}
25+
end
26+
27+
context "when having valid license" do
28+
it "can get all users", :smoke do
29+
get(request_url, platform.superuser).should look_like({
30+
:status => 200,
31+
:body => users_body
32+
})
33+
end
34+
end
35+
36+
# context "failure case", automate: true do
37+
context "when not having valid license", if: ENV["IS_AUTOMATE"] == "true" do
38+
before(:all) do
39+
puts "applying expired license"
40+
puts ENV['A2_EXPIRED_LICENSE']
41+
system("chef-automate license apply -f \"eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImEwYmMzZmMxLWFiOGUtNDI4ZC1hODZiLTU5MTE4ZDM3ZjYzOSIsInZlcnNpb24iOiIxIiwidHlwZSI6InRyaWFsIiwiZ2VuZXJhdG9yIjoiY2hlZi9saWNlbnNlLTIuMC4wIiwia2V5X3NoYTI1NiI6ImUwZGYyOGM4YmM2ODE1MGVkYmZlZjk4Y2Q2YjdkYzQzOWMxZjgwYzdlN2VmNzQ3ODkzYTY4OTNhMmY3YjYwZjciLCJnZW5lcmF0aW9uX2RhdGUiOnsic2Vjb25kcyI6MTcxOTY2NzUxM30sImN1c3RvbWVyIjoiU3RhbmRhcmQgQmFuayBSZW5ld2FsIFN0YXJ0IERhdGUgMjAyNC0wNy0wMSIsImN1c3RvbWVyX2lkIjoiNTRBOTNGOUEtOEE2RC00RERGLUJCQTktRkE4MDE0MkQxNTI1IiwiY3VzdG9tZXJfaWRfdmVyc2lvbiI6IjEiLCJlbnRpdGxlbWVudHMiOlt7Im5hbWUiOiJDaGVmIEF1dG9tYXRlIiwibWVhc3VyZSI6Im5vZGVzIiwibGltaXQiOi0xLCJzdGFydCI6eyJzZWNvbmRzIjoxNzE5NjE5MjAwfSwiZW5kIjp7InNlY29uZHMiOjE3MjIyOTc1OTl9fV19.AErwHcnIs7TQoWPEj35Fj-_zPOPIHAXH1YBpm7pUItchNhAMJhdlajhIlS0byVhmS479jf9mn9uCGTos9vsy4w9eAZV2uUUlXB9uOzd6QWEv_FpX2_CsfrpNQfkRiaZ21IgKySXEfmoNbbLWBXPC9lOxhwg2HkbH4aB0lkBUVqTHwE9D\"")
42+
system("sleep 100")
43+
puts "expired license applied"
44+
puts system("chef-automate license status")
45+
end
46+
after(:all) do
47+
system("chef-automate license apply \"$A2_LICENSE\"")
48+
system("sleep 100")
49+
puts "valid license applied"
50+
puts system("chef-automate license status")
51+
end
52+
53+
it "returns 403", :smoke do
54+
puts get(request_url, platform.superuser)
55+
get(request_url, platform.superuser).should look_like({
56+
:status => 403
57+
})
58+
end
59+
# it "can get status", automate: true do
60+
# get(status_url, platform.superuser).should look_like({
61+
# :status => 200
62+
# })
63+
# end
64+
end
65+
end # context /users/<name> endpoint
66+
end # describe users

0 commit comments

Comments
 (0)