deadwood 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.
Files changed (77) hide show
  1. data/COPYING +19 -0
  2. data/README.md +19 -0
  3. data/Rakefile +65 -0
  4. data/examples/deadwood-config.yml +5 -0
  5. data/lib/deadwood.rb +45 -0
  6. data/lib/deadwood/active_resource_oauth_client.rb +74 -0
  7. data/lib/deadwood/model/activation_key.rb +24 -0
  8. data/lib/deadwood/model/base.rb +82 -0
  9. data/lib/deadwood/model/changeset.rb +28 -0
  10. data/lib/deadwood/model/consumer.rb +18 -0
  11. data/lib/deadwood/model/crl.rb +18 -0
  12. data/lib/deadwood/model/entitlement.rb +18 -0
  13. data/lib/deadwood/model/environment.rb +40 -0
  14. data/lib/deadwood/model/errata.rb +18 -0
  15. data/lib/deadwood/model/gpg_key.rb +37 -0
  16. data/lib/deadwood/model/organization.rb +21 -0
  17. data/lib/deadwood/model/pool.rb +18 -0
  18. data/lib/deadwood/model/product.rb +33 -0
  19. data/lib/deadwood/model/provider.rb +24 -0
  20. data/lib/deadwood/model/repository.rb +18 -0
  21. data/lib/deadwood/model/role.rb +38 -0
  22. data/lib/deadwood/model/status.rb +18 -0
  23. data/lib/deadwood/model/subscription.rb +18 -0
  24. data/lib/deadwood/model/system.rb +24 -0
  25. data/lib/deadwood/model/system_group.rb +33 -0
  26. data/lib/deadwood/model/task.rb +18 -0
  27. data/lib/deadwood/model/template.rb +24 -0
  28. data/lib/deadwood/model/user.rb +28 -0
  29. data/lib/deadwood/model/version.rb +18 -0
  30. data/rake/rpmtask.rb +126 -0
  31. data/spec/models/activation_key_spec.rb +35 -0
  32. data/spec/models/base_spec.rb +30 -0
  33. data/spec/models/changeset_spec.rb +38 -0
  34. data/spec/models/crl_spec.rb +25 -0
  35. data/spec/models/environment_spec.rb +54 -0
  36. data/spec/models/gpg_key_spec.rb +30 -0
  37. data/spec/models/organization_spec.rb +75 -0
  38. data/spec/models/product_spec.rb +38 -0
  39. data/spec/models/provider_spec.rb +72 -0
  40. data/spec/models/repository_spec.rb +36 -0
  41. data/spec/models/role_spec.rb +57 -0
  42. data/spec/models/system_group_spec.rb +31 -0
  43. data/spec/models/task_spec.rb +26 -0
  44. data/spec/models/template_spec.rb +37 -0
  45. data/spec/models/user_spec.rb +53 -0
  46. data/spec/spec_helper.rb +50 -0
  47. data/spec/vcr/cassettes/create_activation_key.yml +255 -0
  48. data/spec/vcr/cassettes/create_changeset.yml +257 -0
  49. data/spec/vcr/cassettes/create_find_all_environment.yml +130 -0
  50. data/spec/vcr/cassettes/create_find_single_environment.yml +130 -0
  51. data/spec/vcr/cassettes/create_gpg_key.yml +173 -0
  52. data/spec/vcr/cassettes/create_provider_for_default_org.yml +171 -0
  53. data/spec/vcr/cassettes/create_repository.yml +261 -0
  54. data/spec/vcr/cassettes/create_role.yml +130 -0
  55. data/spec/vcr/cassettes/create_system.yml +171 -0
  56. data/spec/vcr/cassettes/create_template.yml +253 -0
  57. data/spec/vcr/cassettes/create_user.yml +130 -0
  58. data/spec/vcr/cassettes/create_user_role.yml +263 -0
  59. data/spec/vcr/cassettes/find_ACME_Corporation.yml +44 -0
  60. data/spec/vcr/cassettes/find_admin.yml +44 -0
  61. data/spec/vcr/cassettes/find_crl.yml +62 -0
  62. data/spec/vcr/cassettes/find_template.yml +44 -0
  63. data/spec/vcr/cassettes/find_users.yml +44 -0
  64. data/spec/vcr/cassettes/organization_1_exists.yml +85 -0
  65. data/spec/vcr/cassettes/organization_create.yml +128 -0
  66. data/spec/vcr/cassettes/organization_default_exists.yml +44 -0
  67. data/spec/vcr/cassettes/organization_exists.yml +44 -0
  68. data/spec/vcr/cassettes/organization_update.yml +130 -0
  69. data/spec/vcr/cassettes/provider_1_exists.yml +44 -0
  70. data/spec/vcr/cassettes/providers_all_exists.yml +44 -0
  71. data/spec/vcr/cassettes/read_products.yml +257 -0
  72. data/spec/vcr/cassettes/update_environment_name_description.yml +216 -0
  73. data/spec/vcr/cassettes/update_provider_for_org.yml +175 -0
  74. data/spec/vcr/cassettes/update_role.yml +175 -0
  75. data/spec/vcr/cassettes/update_user.yml +130 -0
  76. data/spec/vcr_setup.rb +46 -0
  77. metadata +242 -0
@@ -0,0 +1,35 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::ActivationKey do
18
+ let(:org_id) { "ACME_Corporation" }
19
+ it "should create an activation key and be able to search for it and then destroy them" do
20
+ VCR.use_cassette 'create_activation_key' do
21
+ env = Deadwood::Katello::Environment.new(:name => 'Test', :prior => 1, :organization_id => org_id)
22
+ env.save
23
+ activation_key = Deadwood::Katello::ActivationKey.new(:name => 'test_activation_key', :description => 'test_description', :environment_id => env.id)
24
+ activation_key.save
25
+ activation_key.nil?.should be_false
26
+ activation_keys = Deadwood::Katello::ActivationKey.find(:all, :from=> "/katello/api/organizations/#{org_id}/activation_keys")
27
+ activation_keys.nil?.should be_false
28
+ activation_keys.each do |key|
29
+ key.destroy
30
+ end
31
+ activation_keys = Deadwood::Katello::ActivationKey.find(:all, :from=> "/katello/api/organizations/#{org_id}/activation_keys")
32
+ env.destroy
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'timecop'
14
+
15
+ describe Deadwood::Katello::Base do
16
+ it "should use_oauth? if configuration is present" do
17
+ Deadwood::Katello::Base.config = {
18
+ :site => 'https://10.11.230.105',
19
+ :consumer_key => 'cloud_forms',
20
+ :consumer_secret => 'MvhGuh1kLtOAelq5h/ebfcjW'
21
+ }
22
+ Deadwood::Katello::Base.use_oauth?.should be_true
23
+ end
24
+
25
+ context "should use_oauth? if configuration is present" do
26
+ use_vcr_cassette "oauth_success_valid" do
27
+ Deadwood::Katello::Organization.find(:all)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::Changeset do
18
+ let(:org_id) { "ACME_Corporation" }
19
+ it "should create a changeset then find it and delete it" do
20
+ VCR.use_cassette 'create_changeset' do
21
+ env = Deadwood::Katello::Environment.new(:name => 'Test', :prior => 1, :organization_id => org_id)
22
+ env.save
23
+ changeset = Deadwood::Katello::Changeset.new(:name => 'test_changeset', :description => 'test_description', :environment_id => env.id, :organization_id => org_id)
24
+ changeset.save
25
+ changeset.nil?.should be_false
26
+
27
+ changesets = Deadwood::Katello::Changeset.find(:all, :from=> "/katello/api/organizations/#{org_id}/environments/#{env.id}/changesets")
28
+ changesets.nil?.should be_false
29
+ changesets.each do |cs|
30
+ cs.destroy
31
+ end
32
+
33
+ changesets = Deadwood::Katello::Changeset.find(:all, :from=> "/katello/api/organizations/#{org_id}/environments/#{env.id}/changesets")
34
+ changesets.empty?.should be_true
35
+ env.destroy
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,25 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::Crl do
18
+ it "should retrieve the crl" do
19
+ VCR.use_cassette 'find_crl' do
20
+ crl = Deadwood::Katello::Crl.find(:all)
21
+ crl.nil?.should be_false
22
+ crl.include?("-----BEGIN X509 ").should be_true
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::Environment do
18
+ let(:org_id) { 'ACME_Corporation' }
19
+ it "should create an environment then delete it" do
20
+ VCR.use_cassette 'create_find_all_environment' do
21
+ env = Deadwood::Katello::Environment.new(:name => 'Test', :prior => 1, :organization_id => org_id)
22
+ env.save
23
+ env = Deadwood::Katello::Environment.find(:all, :from => "/katello/api/organizations/#{org_id}/environments")[1]
24
+ env.nil?.should be_false
25
+ env.name.include?('Test').should be_true
26
+ env.destroy
27
+ end
28
+ end
29
+
30
+ it "should create an environment look it up by id and then delete it" do
31
+ VCR.use_cassette 'create_find_single_environment' do
32
+ env = Deadwood::Katello::Environment.new(:name => 'Test', :prior => 1, :organization_id => org_id)
33
+ env.save
34
+ env = Deadwood::Katello::Environment.find(env.id, :from => "/katello/api/organizations/#{org_id}/environments")
35
+ env.nil?.should be_false
36
+ env.name.include?('Test').should be_true
37
+ env.destroy
38
+ end
39
+ end
40
+
41
+ it "should update and environment name and description" do
42
+ VCR.use_cassette 'update_environment_name_description' do
43
+ env = Deadwood::Katello::Environment.new(:name => 'Test', :prior => 1, :organization_id => org_id)
44
+ env.save
45
+ env = Deadwood::Katello::Environment.find(env.id, :from => "/katello/api/organizations/#{org_id}/environments")
46
+ env.description = 'Test update'
47
+ env.save
48
+ env = Deadwood::Katello::Environment.find(env.id, :from => "/katello/api/organizations/#{org_id}/environments")
49
+ env.nil?.should be_false
50
+ env.description.include?('Test update').should be_true
51
+ env.destroy
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::GpgKey do
18
+ let(:org_id) { 'ACME_Corporation' }
19
+ it "should create a gpg key, read it, updated it, and delete it for ACME_Corporation" do
20
+ VCR.use_cassette 'create_gpg_key' do
21
+ gpg_key = Deadwood::Katello::GpgKey.new(:name => 'Test-GPG-Key', :content => "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1.4.11 (GNU/Linux)\n\nmQENBE8NW6EBCAC/ht3UujFwxol44zilXcwI8v15gf6X4u3A5Oo2FCEweQfbZw8q\nlPGjzRNHcNVO4NIZ+G1fHyWAgcs/xa4fTju4LOJU2OWfbkvGA7tlIIREkEQ9IgMI\ni0LJzsHyqhWhJ0S5POCLFyH27R0Vh2wPMwZawoomRVDsghIE8TAJVKIHICVObvGE\nVqBGSY1OHvGfZ0ZsnQv3hDmxnyywJkJ96HGVqStS2sW0YkQ77dRY0u6eSI55vwBQ\niV9dCSMs43LpoBL9pFj0ESM76G0GSGF5G9PH2b//y8ehepdS30otiqgjag5Zw76b\nqFMHFyq1o5hXJpIPiZaagU1X+wMixPOlqE5LABEBAAG0MER1bW15IFBhY2thZ2Vz\nIEdlbmVyYXRvciA8YWRtaW5Aem9vLmV4YW1wbGUuY29tPokBOAQTAQIAIgUCTw1b\noQIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQ74XM4/ePsZVeCgf+L+HW\nf0K7/uzu3Q7G+aOu7qwu0iUK64SEAgtoMdjpjkq+YYxPS60zP7QS3pAzL4N31kT/\nkHQ+OJAg5Z0oegXu9mdhIenks2DaEzN6P2jAhWoRa/az5F9AaJ01WSsspsBpcAyt\n3NB2iGNtzs4v6saUz5mTp1bgmsXolzClHlTSUnjjCfuk7HgzJcCpRxb49tQ5Lo3b\n9k0XPvhhgSdiTFM+CfPl3qgHPENZqyoDOnhvKbMHZg8NCf1NLf8edlk5nWDjHti8\nVfkuCSgRzR15SgyEUU1MCQBPEYKy8U6LoOwX8Rl3+lCf9D7rReP74wSEdr9p9cFi\nSCFpN6IUJ9pN0tDU3rkBDQRPDVuhAQgAmZB+DKbraTgeW1UOYS/HWzGOR21NR3nq\nsxeG249W3OlsZbk/8BJP/DqFAhVbdxvISFkSKURoVXxUwoKx36KZHXIOgCt3vsj5\nu2mxF2ajrHBwzM8jrrNy8xdd4DplOP2D0DbuswDi5pqmd/Cd0EdC88ZIPt3Ox/GH\n4uCJOzkCRFcFRZhOT+YC+A3YaVg4UoR3AMup8K81Nm2y8q1pUy/gZvkWMONy5iDX\nlyU6enBNv+vmhumyYJT8+rPRW/ztsaBzkvpuXkQTJdWDQbigeK1hBNV5PCjyQydj\nP+sKrMxKjyyZ0rcGP1hcCqZuBHZlW0O2WJFKsZv+fY8UJfU08FeAqQARAQABiQEf\nBBgBAgAJBQJPDVuhAhsMAAoJEO+FzOP3j7GVhlsH/0emlW/Nk0bSUG4jfAeJAB7H\nKRYbr5P/YbbFLEOb4yi2DlPxUac0JoXCMLha9G9LBmQ4IL4qPHdycSlEs4cGBX6W\nxn1ti6rJ3LWm5Hb7iUBfIeuKW31thTJK7SAruiBk7g1/I55HlFW0LEfgfVUQf6hJ\n9Rnw6YVXyQAod1x/QmLWw5aQcoksHL/4eRpU74EjuKQdZMLuaherKtY6OTtEDTdm\nbEdEINVqR5hYEHgDEPPrPb5MDbQsrMEAwdWPqC2/9cgacO33/VuvXDu74X+TwE/c\nOGRCb385XPNS9KApQ4iRTZ6ccOnSJumZbeTTd9DBFwa+T1/xD96yabnaOdJqf6Y=\n=RrIG\n-----END PGP PUBLIC KEY BLOCK-----\n", :organization_id => org_id)
22
+ gpg_key.save
23
+
24
+ gpg_key = Deadwood::Katello::GpgKey.find(gpg_key.id)
25
+ gpg_key.update_attributes(:name => 'Renamed-Test-GPG-Key')
26
+
27
+ gpg_key.destroy
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,75 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::Organization do
18
+ let(:org_id) { "ACME_Corporation" }
19
+ it "should find an org if an org exists" do
20
+ VCR.use_cassette 'organization_exists' do
21
+ orgs = Deadwood::Katello::Organization.find(:all)
22
+ (orgs.size > 0).should be_true
23
+ end
24
+ end
25
+
26
+ it "should find ACME_Corporation" do
27
+ VCR.use_cassette 'find_ACME_Corporation' do
28
+ org = Deadwood::Katello::Organization.find(:first, :name => org_id)
29
+ org.nil?.should be_false
30
+ end
31
+ end
32
+
33
+ it "should find the default organization if default organization exists" do
34
+ VCR.use_cassette 'organization_default_exists' do
35
+ org = Deadwood::Katello::Organization.find(:all).first
36
+ org.nil?.should be_false
37
+ (org.id == 1).should be_true
38
+ end
39
+ end
40
+
41
+ it "should find default organization by id if the organization exists" do
42
+ VCR.use_cassette 'organization_1_exists' do
43
+ default_org = Deadwood::Katello::Organization.find(:all).first
44
+ org = Deadwood::Katello::Organization.find(default_org.cp_key)
45
+ org.nil?.should be_false
46
+ end
47
+ end
48
+
49
+ it "should update the default organization name if the organization exists" do
50
+ VCR.use_cassette 'organization_update' do
51
+ default_org = Deadwood::Katello::Organization.find(:all).first
52
+
53
+ # Need to remove the attributes that are protected by katello
54
+ default_org.attributes.delete(:task_id)
55
+ default_org.attributes.delete(:service_levels)
56
+ default_org.attributes.delete(:updated_at)
57
+ default_org.attributes.delete(:created_at)
58
+ default_org.attributes.delete(:cp_key)
59
+ # Make our description update
60
+ default_org.update_attribute(:description, "Updated description")
61
+ default_org = Deadwood::Katello::Organization.find(:all).first
62
+ default_org.description.include?("Updated description").should be_true
63
+ end
64
+ end
65
+
66
+ it "should create an organization" do
67
+ VCR.use_cassette 'organization_create' do
68
+ org = Deadwood::Katello::Organization.new({:name => 'Test_Org_Name', :description => 'Test Description'})
69
+ created = org.save
70
+ created.should be_true
71
+ org = Deadwood::Katello::Organization.find('Test_Org_Name')
72
+ Deadwood::Katello::Organization.delete(org.name)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::Product do
18
+ let(:org_id) { 'ACME_Corporation' }
19
+ it "should create and read products for ACME_Corporation then delete them" do
20
+ VCR.use_cassette 'read_products' do
21
+ provider = Deadwood::Katello::Provider.new(:organization_id => org_id, :provider_type => 'Custom', :repository_url => 'http://repo.example.com', :name => 'test_provider_name', :description => 'Test provider description')
22
+ provider.save
23
+ product = Deadwood::Katello::Product.new(:provider_id => provider.id, :name => 'Test_product', :description => 'Test description')
24
+ product.save
25
+ products = Deadwood::Katello::Product.find(:all, :from => "/katello/api/organizations/#{org_id}/products")
26
+ products.nil?.should be_false
27
+ products.empty?.should be_false
28
+ products[0].name.include?('Test_product').should be_true
29
+ product.organization_id = org_id
30
+ product.destroy
31
+ provider.destroy
32
+ products = Deadwood::Katello::Product.find(:all, :from => "/katello/api/organizations/#{org_id}/products")
33
+ products.empty?.should be_true
34
+
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,72 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::Organization do
18
+ let(:org_id) { "ACME_Corporation" }
19
+ it "should find a provider if a provider exists" do
20
+ VCR.use_cassette 'provider_1_exists' do
21
+ provider = Deadwood::Katello::Provider.find(1)
22
+ provider.nil?.should be_false
23
+ end
24
+ end
25
+
26
+ it "should find all providers if all providers exist" do
27
+ VCR.use_cassette 'providers_all_exists' do
28
+ providers = Deadwood::Katello::Provider.find(:all, :from=> "/katello/api/organizations/#{org_id}/providers")
29
+ providers.nil?.should be_false
30
+ end
31
+
32
+ end
33
+
34
+ it "should update a provider" do
35
+ VCR.use_cassette 'update_provider_for_org' do
36
+ provider = Deadwood::Katello::Provider.find(1)
37
+ provider.attributes.delete(:provider_type)
38
+ provider.attributes.delete(:organization_id)
39
+ provider.attributes.delete(:created_at)
40
+ provider.attributes.delete(:task_status_id)
41
+ provider.attributes.delete(:sync_state)
42
+ provider.attributes.delete(:description)
43
+ provider.attributes.delete(:updated_at)
44
+ provider.attributes.delete(:last_sync)
45
+ provider.attributes.delete(:name)
46
+ provider.update_attribute(:repository_url, 'https://cdn.redhat.tv')
47
+ provider = Deadwood::Katello::Provider.find(1)
48
+ (provider.repository_url.include? 'https://cdn.redhat.tv').should be_true
49
+ provider.attributes.delete(:provider_type)
50
+ provider.attributes.delete(:organization_id)
51
+ provider.attributes.delete(:created_at)
52
+ provider.attributes.delete(:task_status_id)
53
+ provider.attributes.delete(:sync_state)
54
+ provider.attributes.delete(:description)
55
+ provider.attributes.delete(:updated_at)
56
+ provider.attributes.delete(:last_sync)
57
+ provider.attributes.delete(:name)
58
+ provider.update_attribute(:repository_url, 'https://cdn.redhat.com')
59
+ end
60
+ end
61
+
62
+ it "should create a provider" do
63
+ VCR.use_cassette 'create_provider_for_default_org' do
64
+ size = Deadwood::Katello::Provider.find(:all, :from=> "/katello/api/organizations/#{org_id}/providers").size
65
+ provider = Deadwood::Katello::Provider.new(:organization_id => 'ACME_Corporation', :provider_type => 'Custom', :repository_url => 'http://repo.example.com', :name => 'test_provider_name', :description => 'Test provider description')
66
+ provider.save
67
+ new_size = Deadwood::Katello::Provider.find(:all, :from=> "/katello/api/organizations/#{org_id}/providers").size
68
+ (new_size == size + 1).should be_true
69
+ provider.destroy
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::Repository do
18
+ let(:org_id) { 'ACME_Corporation' }
19
+ it "should create a repository, read it and then delete it for ACME_Corporation" do
20
+ VCR.use_cassette 'create_repository' do
21
+ provider = Deadwood::Katello::Provider.new(:organization_id => 'ACME_Corporation', :provider_type => 'Custom', :repository_url => 'http://repo.example.com', :name => 'test_provider_name', :description => 'Test provider description')
22
+ provider.save
23
+ product = Deadwood::Katello::Product.new(:provider_id => provider.id, :name => 'Test_product', :description => 'Test description')
24
+ product.save
25
+
26
+ repo = Deadwood::Katello::Repository.new(:url => 'http://repo.example.com/repos', :name => 'Test_Repo', :organization_id => org_id, :product_id => product.id)
27
+ repo.save
28
+
29
+ repo = Deadwood::Katello::Repository.find(repo.id)
30
+ repo.nil?.should be_false
31
+ repo.name.include?('Test_Repo').should be_true
32
+ repo.destroy
33
+ provider.destroy
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,57 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ require 'spec_helper'
14
+ require 'timecop'
15
+ require 'vcr'
16
+
17
+ describe Deadwood::Katello::Role do
18
+ let(:org_id) { 'ACME_Corporation' }
19
+ it "creates a role" do
20
+ VCR.use_cassette 'create_role' do
21
+ role = Deadwood::Katello::Role.new(:name => 'test_role_name', :description => 'test role description')
22
+ role.save
23
+ roles = Deadwood::Katello::Role.find(:all)
24
+ roles.last.name.include?('test_role_name').should be_true
25
+ role.destroy
26
+ end
27
+ end
28
+
29
+ it "creates a role and assigns it to a user" do
30
+ VCR.use_cassette 'create_user_role' do
31
+ role = Deadwood::Katello::Role.new(:name => 'test_role_name', :description => 'test role description')
32
+ role.save
33
+
34
+ user = Deadwood::Katello::User.new(:username => 'funzo', :email => 'spam@example.com', :password => 'secretpw', :disabled => false)
35
+ user.save
36
+ user_role = Deadwood::Katello::Role.new(:user_id => user.id, :name => 'test_role', :description => 'test role description', :role_id => role.id)
37
+ user_role.save
38
+
39
+ roles = Deadwood::Katello::Role.find(:all, :from => "/katello/api/users/#{user.id}/roles")
40
+ roles.empty?.should be_false
41
+ user.destroy
42
+ role.destroy
43
+ end
44
+ end
45
+
46
+ it "creates, updates, and deletes a role" do
47
+ VCR.use_cassette 'update_role' do
48
+ role = Deadwood::Katello::Role.new(:name => 'test_role_name', :description => 'test role description')
49
+ role.save
50
+ roles = Deadwood::Katello::Role.find(:all)
51
+ roles.last.name.include?('test_role_name').should be_true
52
+
53
+ role.update_attributes(:name => 'test_role_name_updated')
54
+ role.destroy
55
+ end
56
+ end
57
+ end