Skip to content

Commit

Permalink
Make org creation optional in APIv1 spec
Browse files Browse the repository at this point in the history
Also remove use of global $org variable.
  • Loading branch information
danielsdeleo committed Feb 25, 2016
1 parent 0105233 commit 2185795
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions oc-chef-pedant/spec/api/versioned_behaviors/server_api_v1_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@
context "[v1+]" do
shared(:pubkey_regex) { /^(-----BEGIN (RSA )?PUBLIC KEY)/ }
shared(:privkey_regex) { /^(-----BEGIN (RSA )?PRIVATE KEY)/ }
shared(:org_name) { @org_name ||= unique_name("api-v1-org")}

shared(:org_name) do
if Pedant.config[:org][:create_me]
unique_name("api-v1-org")
else
Pedant.config[:org][:name]
end
end

shared(:org_client_url){ "#{platform.server}/organizations/#{org_name}/clients" }
shared(:user_url){ "#{platform.server}/users" }
shared(:client_name) { unique_name("api-v1-client") }
shared(:user_name) { unique_name("api-v1-user") }
shared(:named_client_url) { "#{org_client_url}/#{client_name}" }
shared(:named_user_url) { "#{user_url}/#{user_name}" }
shared(:valid_pubkey) { @valid_pubkey ||= platform.gen_rsa_key("client-v1-test")[:public]}
shared(:org) { $org }
shared(:default_client_payload) {
{
"name" => client_name,
Expand All @@ -38,11 +45,16 @@
# Note that a client is created by the server during org creation,
# so we'll want to set our api version from the start.
platform.use_max_server_api_version
$org = platform.create_org(org_name)

if Pedant.config[:org][:create_me]
platform.create_org(org_name)
end
end

after(:all) do
platform.delete_org(org_name)
if Pedant.config[:org][:create_me]
platform.delete_org(org_name)
end
platform.reset_server_api_version
end
context "org creation", :organizations do
Expand Down

0 comments on commit 2185795

Please sign in to comment.