runcible 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +19 -0
  3. data/LICENSE +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +37 -0
  6. data/lib/runcible.rb +25 -0
  7. data/lib/runcible/base.rb +113 -0
  8. data/lib/runcible/extensions/repository.rb +67 -0
  9. data/lib/runcible/oauth_setup.rb +29 -0
  10. data/lib/runcible/resources/repository.rb +82 -0
  11. data/lib/runcible/resources/role.rb +46 -0
  12. data/lib/runcible/resources/task.rb +49 -0
  13. data/lib/runcible/resources/user.rb +50 -0
  14. data/lib/runcible/version.rb +3 -0
  15. data/rel-eng/packages/.readme +3 -0
  16. data/rel-eng/tito.props +5 -0
  17. data/runcible.gemspec +17 -0
  18. data/runcible.spec +48 -0
  19. data/test/.gitkeep +0 -0
  20. data/test/integration/extensions/repository_test.rb +117 -0
  21. data/test/integration/fixtures/repositories/zoo5/.treeinfo +12 -0
  22. data/test/integration/fixtures/repositories/zoo5/CHANGESET +11 -0
  23. data/test/integration/fixtures/repositories/zoo5/PULP_MANIFEST +1 -0
  24. data/test/integration/fixtures/repositories/zoo5/cheetah-0.3-0.8.noarch.rpm +0 -0
  25. data/test/integration/fixtures/repositories/zoo5/create.sh +20 -0
  26. data/test/integration/fixtures/repositories/zoo5/elephant-0.3-0.8.noarch.rpm +0 -0
  27. data/test/integration/fixtures/repositories/zoo5/empty.iso +0 -0
  28. data/test/integration/fixtures/repositories/zoo5/giraffe-0.3-0.8.noarch.rpm +0 -0
  29. data/test/integration/fixtures/repositories/zoo5/images/test1.img +0 -0
  30. data/test/integration/fixtures/repositories/zoo5/images/test2.img +0 -0
  31. data/test/integration/fixtures/repositories/zoo5/lion-0.3-0.8.noarch.rpm +0 -0
  32. data/test/integration/fixtures/repositories/zoo5/monkey-0.3-0.8.noarch.rpm +0 -0
  33. data/test/integration/fixtures/repositories/zoo5/penguin-0.3-0.8.noarch.rpm +0 -0
  34. data/test/integration/fixtures/repositories/zoo5/repodata/06661e2a9839cf0beebcf409410ca4f93c09081f4e772fd0d03e1faf62705a11-comps.xml +39 -0
  35. data/test/integration/fixtures/repositories/zoo5/repodata/0c4d57a68f9a3b13dabc6f8b01ca8958aa796167cececee04717edfc26d02f2d-other.xml.gz +0 -0
  36. data/test/integration/fixtures/repositories/zoo5/repodata/298ce23f48b3613e030d19f3d9c2ff2df31c2f08479bdf94cebb87c208e48c0e-filelists.xml.gz +0 -0
  37. data/test/integration/fixtures/repositories/zoo5/repodata/32c0e38317aade0c057b173ff62344e912e1bd650409c6ac31aecee78e3413af-comps.xml.gz +0 -0
  38. data/test/integration/fixtures/repositories/zoo5/repodata/34d954906c7ce7aa2254e24d7be0a9049e0a2f436add023ca056123a2d48e30e-updateinfo.xml.gz +0 -0
  39. data/test/integration/fixtures/repositories/zoo5/repodata/63aedd074d9f0daf7c6be8c61f91d76a962bb6ceda86b9abd2140f154c320fa2-other.sqlite.bz2 +0 -0
  40. data/test/integration/fixtures/repositories/zoo5/repodata/69d65cdebffc6199d3adb3e38b06ca9abaae6c1c7366805099987b28f182178d-filelists.sqlite.bz2 +0 -0
  41. data/test/integration/fixtures/repositories/zoo5/repodata/799241a518a4a6b11a68f8e6fbdb719875f87832f60accc0851ced0d6a0497c6-updateinfo.xml.gz +0 -0
  42. data/test/integration/fixtures/repositories/zoo5/repodata/a4ea9fcdce31dc8673c7a9ba66c086bd6a16e1eff717e3896dd1cac444a1423c-primary.xml.gz +0 -0
  43. data/test/integration/fixtures/repositories/zoo5/repodata/fb9b9508e148368d0edf7e03dc905b343937fd958e6531cce6380933d18c3455-primary.sqlite.bz2 +0 -0
  44. data/test/integration/fixtures/repositories/zoo5/repodata/repomd.xml +75 -0
  45. data/test/integration/fixtures/repositories/zoo5/squirrel-0.3-0.8.noarch.rpm +0 -0
  46. data/test/integration/fixtures/repositories/zoo5/updateinfo.xml +26 -0
  47. data/test/integration/fixtures/repositories/zoo5/walrus-0.3-0.8.noarch.rpm +0 -0
  48. data/test/integration/fixtures/vcr_cassettes/extensions/pulp_repository_extensions.yml +137 -0
  49. data/test/integration/fixtures/vcr_cassettes/pulp_consumer.yml +1529 -0
  50. data/test/integration/fixtures/vcr_cassettes/pulp_consumer_group.yml +430 -0
  51. data/test/integration/fixtures/vcr_cassettes/pulp_consumer_helper.yml +120 -0
  52. data/test/integration/fixtures/vcr_cassettes/pulp_distribution.yml +77 -0
  53. data/test/integration/fixtures/vcr_cassettes/pulp_errata.yml +77 -0
  54. data/test/integration/fixtures/vcr_cassettes/pulp_filter.yml +233 -0
  55. data/test/integration/fixtures/vcr_cassettes/pulp_filter_helper.yml +81 -0
  56. data/test/integration/fixtures/vcr_cassettes/pulp_package.yml +155 -0
  57. data/test/integration/fixtures/vcr_cassettes/pulp_package_group.yml +40 -0
  58. data/test/integration/fixtures/vcr_cassettes/pulp_package_group_category.yml +40 -0
  59. data/test/integration/fixtures/vcr_cassettes/pulp_ping.yml +40 -0
  60. data/test/integration/fixtures/vcr_cassettes/pulp_repository.yml +1196 -0
  61. data/test/integration/fixtures/vcr_cassettes/pulp_repository_helper.yml +8659 -0
  62. data/test/integration/fixtures/vcr_cassettes/pulp_repository_sync.yml +215 -0
  63. data/test/integration/fixtures/vcr_cassettes/pulp_role.yml +133 -0
  64. data/test/integration/fixtures/vcr_cassettes/pulp_roles.yml +120 -0
  65. data/test/integration/fixtures/vcr_cassettes/pulp_task.yml +943 -0
  66. data/test/integration/fixtures/vcr_cassettes/pulp_user.yml +288 -0
  67. data/test/integration/fixtures/vcr_cassettes/pulp_user_helper.yml +195 -0
  68. data/test/integration/resources/helpers/consumer_helper.rb +49 -0
  69. data/test/integration/resources/helpers/filter_helper.rb +44 -0
  70. data/test/integration/resources/helpers/repository_helper.rb +127 -0
  71. data/test/integration/resources/pulp_consumer_group_test.rb +182 -0
  72. data/test/integration/resources/pulp_consumer_test.rb +200 -0
  73. data/test/integration/resources/pulp_distribution_test.rb +55 -0
  74. data/test/integration/resources/pulp_errata_test.rb +60 -0
  75. data/test/integration/resources/pulp_filter_test.rb +92 -0
  76. data/test/integration/resources/pulp_package_group_category_test.rb +55 -0
  77. data/test/integration/resources/pulp_package_group_test.rb +56 -0
  78. data/test/integration/resources/pulp_package_test.rb +79 -0
  79. data/test/integration/resources/pulp_ping_test.rb +31 -0
  80. data/test/integration/resources/pulp_repository_test.rb +307 -0
  81. data/test/integration/resources/pulp_role_test.rb +62 -0
  82. data/test/integration/resources/pulp_task_test.rb +79 -0
  83. data/test/integration/resources/pulp_user_test.rb +105 -0
  84. data/test/integration/test_runner.rb +113 -0
  85. data/test/integration/vcr_setup.rb +22 -0
  86. data/test/unit/test_base.rb +62 -0
  87. metadata +218 -0
@@ -0,0 +1,55 @@
1
+ # Copyright 2012 Red Hat, Inc.
2
+ #
3
+ # This software is licensed to you under the GNU General Public
4
+ # License as published by the Free Software Foundation; either version
5
+ # 2 of the License (GPLv2) or (at your option) any later version.
6
+ # There is NO WARRANTY for this software, express or implied,
7
+ # including the implied warranties of MERCHANTABILITY,
8
+ # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
9
+ # have received a copy of GPLv2 along with this software; if not, see
10
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11
+
12
+ require 'rubygems'
13
+ require 'minitest/autorun'
14
+ require 'test/integration/pulp/vcr_pulp_setup'
15
+ require 'test/integration/pulp/helpers/repository_helper'
16
+
17
+
18
+ module TestPulpDistributionBase
19
+ include RepositoryHelper
20
+
21
+ def setup
22
+ @resource = Resources::Pulp::Distribution
23
+ VCR.insert_cassette('pulp_distribution')
24
+ end
25
+
26
+ def teardown
27
+ VCR.eject_cassette
28
+ end
29
+
30
+ end
31
+
32
+
33
+ class TestPulpDistribution < MiniTest::Unit::TestCase
34
+ include TestPulpDistributionBase
35
+
36
+ def self.before_suite
37
+ RepositoryHelper.create_and_sync_repo
38
+ end
39
+
40
+ def self.after_suite
41
+ RepositoryHelper.destroy_repo
42
+ end
43
+
44
+ def test_dist_path
45
+ path = @resource.dist_path
46
+ assert_match("/api/distributions/", path)
47
+ end
48
+
49
+ def test_find
50
+ repo = RepositoryHelper.repo_resource.find(RepositoryHelper.repo_id)
51
+ response = @resource.find(repo['distributionid'].first)
52
+ assert response.length > 0
53
+ end
54
+
55
+ end
@@ -0,0 +1,60 @@
1
+ # Copyright 2012 Red Hat, Inc.
2
+ #
3
+ # This software is licensed to you under the GNU General Public
4
+ # License as published by the Free Software Foundation; either version
5
+ # 2 of the License (GPLv2) or (at your option) any later version.
6
+ # There is NO WARRANTY for this software, express or implied,
7
+ # including the implied warranties of MERCHANTABILITY,
8
+ # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
9
+ # have received a copy of GPLv2 along with this software; if not, see
10
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11
+
12
+ require 'rubygems'
13
+ require 'minitest/autorun'
14
+ require 'test/integration/pulp/vcr_pulp_setup'
15
+ require 'test/integration/pulp/helpers/repository_helper'
16
+
17
+
18
+ module TestPulpErrataBase
19
+
20
+ def setup
21
+ @resource = Resources::Pulp::Errata
22
+ VCR.insert_cassette('pulp_errata')
23
+ end
24
+
25
+ def teardown
26
+ VCR.eject_cassette
27
+ end
28
+
29
+ end
30
+
31
+
32
+ class TestPulpErrata < MiniTest::Unit::TestCase
33
+ include TestPulpErrataBase
34
+
35
+ def self.before_suite
36
+ RepositoryHelper.create_and_sync_repo
37
+ end
38
+
39
+ def self.after_suite
40
+ RepositoryHelper.destroy_repo
41
+ end
42
+
43
+ def test_errata_path
44
+ path = @resource.errata_path
45
+ assert_match("/api/errata/", path)
46
+ end
47
+
48
+ def test_find
49
+ response = @resource.find("RHEA-2010:0002")
50
+ assert response.length > 0
51
+ assert response['id'] == 'RHEA-2010:0002'
52
+ end
53
+
54
+ def test_filter
55
+ response = @resource.filter({ :type => "security" })
56
+ assert response.length > 0
57
+ assert response.select { |errata| errata['id'] == "RHEA-2010:0002" }.length > 0
58
+ end
59
+
60
+ end
@@ -0,0 +1,92 @@
1
+ # Copyright 2012 Red Hat, Inc.
2
+ #
3
+ # This software is licensed to you under the GNU General Public
4
+ # License as published by the Free Software Foundation; either version
5
+ # 2 of the License (GPLv2) or (at your option) any later version.
6
+ # There is NO WARRANTY for this software, express or implied,
7
+ # including the implied warranties of MERCHANTABILITY,
8
+ # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
9
+ # have received a copy of GPLv2 along with this software; if not, see
10
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11
+
12
+ require 'rubygems'
13
+ require 'minitest/autorun'
14
+ require 'test/integration/pulp/vcr_pulp_setup'
15
+
16
+
17
+ module TestPulpFilterBase
18
+ def setup
19
+ @resource = Resources::Pulp::Filter
20
+ @filter_id = "integration_test_filter"
21
+ VCR.insert_cassette('pulp_filter')
22
+ end
23
+
24
+ def teardown
25
+ destroy_filter
26
+ VCR.eject_cassette
27
+ end
28
+
29
+ def create_filter
30
+ @resource.create(:id => @filter_id, :type => "blacklist", :package_list => ['cheetah'])
31
+ rescue Exception => e
32
+ end
33
+
34
+ def destroy_filter
35
+ @resource.destroy(@filter_id)
36
+ rescue Exception => e
37
+ end
38
+
39
+ end
40
+
41
+ class TestPulpFilterCreate < MiniTest::Unit::TestCase
42
+ include TestPulpFilterBase
43
+
44
+ def test_create
45
+ response = create_filter
46
+ assert response.length > 0
47
+ assert response['id'] == @filter_id
48
+ end
49
+
50
+ end
51
+
52
+ class TestPulpFilter < MiniTest::Unit::TestCase
53
+ include TestPulpFilterBase
54
+
55
+ def setup
56
+ super
57
+ create_filter
58
+ end
59
+
60
+ def test_path
61
+ path = @resource.path
62
+ assert_match("/api/filters/", path)
63
+ end
64
+
65
+ def test_path_with_id
66
+ path = @resource.path(@filter_id)
67
+ assert_match("/api/filters/" + @filter_id, path)
68
+ end
69
+
70
+ def test_find
71
+ response = @resource.find(@filter_id)
72
+ assert response.length > 0
73
+ assert response['id'] == @filter_id
74
+ end
75
+
76
+ def test_destroy
77
+ response = @resource.destroy(@filter_id)
78
+ assert response == 200
79
+ end
80
+
81
+ def test_add_packages
82
+ response = @resource.add_packages(@filter_id, ['cheetah', 'lion'])
83
+ assert response == "true"
84
+ end
85
+
86
+ def test_remove_packages
87
+ response = @resource.add_packages(@filter_id, ['cheetah', 'lion'])
88
+ response = @resource.remove_packages(@filter_id, ['cheetah', 'lion'])
89
+ assert response == "true"
90
+ end
91
+
92
+ end
@@ -0,0 +1,55 @@
1
+ # Copyright 2012 Red Hat, Inc.
2
+ #
3
+ # This software is licensed to you under the GNU General Public
4
+ # License as published by the Free Software Foundation; either version
5
+ # 2 of the License (GPLv2) or (at your option) any later version.
6
+ # There is NO WARRANTY for this software, express or implied,
7
+ # including the implied warranties of MERCHANTABILITY,
8
+ # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
9
+ # have received a copy of GPLv2 along with this software; if not, see
10
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11
+
12
+ require 'rubygems'
13
+ require 'minitest/autorun'
14
+ require 'test/integration/pulp/vcr_pulp_setup'
15
+ require 'test/integration/pulp/helpers/repository_helper'
16
+
17
+
18
+ module TestPulpPackageGroupCategoryBase
19
+ include RepositoryHelper
20
+
21
+ def setup
22
+ @resource = Resources::Pulp::PackageGroupCategory
23
+ VCR.insert_cassette('pulp_package_group_category')
24
+ end
25
+
26
+ def teardown
27
+ VCR.eject_cassette
28
+ end
29
+
30
+ end
31
+
32
+
33
+ class TestPulpPackageGroupCategory < MiniTest::Unit::TestCase
34
+ include TestPulpPackageGroupCategoryBase
35
+
36
+ def self.before_suite
37
+ RepositoryHelper.create_and_sync_repo
38
+ end
39
+
40
+ def self.after_suite
41
+ RepositoryHelper.destroy_repo
42
+ end
43
+
44
+ def test_path
45
+ path = @resource.path(RepositoryHelper.repo_id)
46
+ assert_match("/api/repositories/" + RepositoryHelper.repo_id + "/packagegroupcategories/", path)
47
+ end
48
+
49
+ def test_all
50
+ response = @resource.all(RepositoryHelper.repo_id)
51
+ assert response.length > 0
52
+ assert response.key?('all')
53
+ end
54
+
55
+ end
@@ -0,0 +1,56 @@
1
+ # Copyright 2012 Red Hat, Inc.
2
+ #
3
+ # This software is licensed to you under the GNU General Public
4
+ # License as published by the Free Software Foundation; either version
5
+ # 2 of the License (GPLv2) or (at your option) any later version.
6
+ # There is NO WARRANTY for this software, express or implied,
7
+ # including the implied warranties of MERCHANTABILITY,
8
+ # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
9
+ # have received a copy of GPLv2 along with this software; if not, see
10
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11
+
12
+ require 'rubygems'
13
+ require 'minitest/autorun'
14
+ require 'test/integration/pulp/vcr_pulp_setup'
15
+ require 'test/integration/pulp/helpers/repository_helper'
16
+
17
+
18
+ module TestPulpPackageGroupBase
19
+ include RepositoryHelper
20
+
21
+ def setup
22
+ @resource = Resources::Pulp::PackageGroup
23
+ VCR.insert_cassette('pulp_package_group')
24
+ end
25
+
26
+ def teardown
27
+ VCR.eject_cassette
28
+ end
29
+
30
+ end
31
+
32
+
33
+ class TestPulpPackageGroup < MiniTest::Unit::TestCase
34
+ include TestPulpPackageGroupBase
35
+
36
+ def self.before_suite
37
+ RepositoryHelper.create_and_sync_repo
38
+ end
39
+
40
+ def self.after_suite
41
+ RepositoryHelper.destroy_repo
42
+ end
43
+
44
+ def test_path
45
+ path = @resource.path(RepositoryHelper.repo_id)
46
+ assert_match("/api/repositories/" + RepositoryHelper.repo_id + "/packagegroups/", path)
47
+ end
48
+
49
+ def test_all
50
+ response = @resource.all(RepositoryHelper.repo_id)
51
+ assert response.length > 0
52
+ assert response.key?('bird')
53
+ assert response.key?('mammal')
54
+ end
55
+
56
+ end
@@ -0,0 +1,79 @@
1
+ # Copyright 2012 Red Hat, Inc.
2
+ #
3
+ # This software is licensed to you under the GNU General Public
4
+ # License as published by the Free Software Foundation; either version
5
+ # 2 of the License (GPLv2) or (at your option) any later version.
6
+ # There is NO WARRANTY for this software, express or implied,
7
+ # including the implied warranties of MERCHANTABILITY,
8
+ # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
9
+ # have received a copy of GPLv2 along with this software; if not, see
10
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11
+
12
+ require 'rubygems'
13
+ require 'minitest/autorun'
14
+ require 'test/integration/pulp/vcr_pulp_setup'
15
+ require 'test/integration/pulp/helpers/repository_helper'
16
+
17
+
18
+ module TestPulpPackageBase
19
+ include RepositoryHelper
20
+
21
+ def setup
22
+ @resource = Resources::Pulp::Package
23
+ VCR.insert_cassette('pulp_package')
24
+ end
25
+
26
+ def teardown
27
+ VCR.eject_cassette
28
+ end
29
+
30
+ end
31
+
32
+
33
+ class TestPulpPackage < MiniTest::Unit::TestCase
34
+ include TestPulpPackageBase
35
+
36
+ def self.before_suite
37
+ RepositoryHelper.create_and_sync_repo
38
+ end
39
+
40
+ def self.after_suite
41
+ RepositoryHelper.destroy_repo
42
+ end
43
+
44
+ def test_package_path
45
+ path = @resource.package_path
46
+ assert_match("/api/packages/", path)
47
+ end
48
+
49
+ def test_all
50
+ response = @resource.all
51
+ assert response.length > 0
52
+ assert response.select { |pack| pack['name'] == 'cheetah' }.length > 0
53
+ end
54
+
55
+ def test_find
56
+ response = @resource.search('cheetah')
57
+ response = @resource.find(response.first['id'])
58
+ assert response.length > 0
59
+ assert response['name'] == 'cheetah'
60
+ end
61
+
62
+ def test_search
63
+ response = @resource.search('cheetah')
64
+ assert response.length > 0
65
+ assert response.first['name'] == 'cheetah'
66
+ end
67
+
68
+ def test_name_search
69
+ response = @resource.name_search('cheetah')
70
+ assert response.length > 0
71
+ assert response.include?('cheetah')
72
+ end
73
+
74
+ def test_dep_solve
75
+ response = @resource.dep_solve(['cheetah', 'lion'], [RepositoryHelper.repo_id])
76
+ assert response.length > 0
77
+ end
78
+
79
+ end
@@ -0,0 +1,31 @@
1
+ # Copyright 2012 Red Hat, Inc.
2
+ #
3
+ # This software is licensed to you under the GNU General Public
4
+ # License as published by the Free Software Foundation; either version
5
+ # 2 of the License (GPLv2) or (at your option) any later version.
6
+ # There is NO WARRANTY for this software, express or implied,
7
+ # including the implied warranties of MERCHANTABILITY,
8
+ # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
9
+ # have received a copy of GPLv2 along with this software; if not, see
10
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11
+
12
+ require 'rubygems'
13
+ require 'minitest/autorun'
14
+ require 'test/integration/pulp/vcr_pulp_setup'
15
+
16
+
17
+ class TestPulpPing < MiniTest::Unit::TestCase
18
+ def setup
19
+ @resource = Resources::Pulp::PulpPing
20
+ VCR.insert_cassette('pulp_ping')
21
+ end
22
+
23
+ def teardown
24
+ VCR.eject_cassette
25
+ end
26
+
27
+ def test_ping
28
+ response = @resource.ping()
29
+ assert response.length > 0
30
+ end
31
+ end
@@ -0,0 +1,307 @@
1
+ # Copyright 2012 Red Hat, Inc.
2
+ #
3
+ # This software is licensed to you under the GNU General Public
4
+ # License as published by the Free Software Foundation; either version
5
+ # 2 of the License (GPLv2) or (at your option) any later version.
6
+ # There is NO WARRANTY for this software, express or implied,
7
+ # including the implied warranties of MERCHANTABILITY,
8
+ # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
9
+ # have received a copy of GPLv2 along with this software; if not, see
10
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11
+
12
+ require 'rubygems'
13
+ require 'minitest/autorun'
14
+
15
+ require './test/integration/resources/helpers/repository_helper'
16
+ require './lib/runcible/resources/repository'
17
+ require './lib/runcible/extensions/repository'
18
+
19
+
20
+ module TestPulpRepositoryBase
21
+ include RepositoryHelper
22
+
23
+ def setup
24
+ @resource = Runcible::Pulp::Repository
25
+ @extension = Runcible::Pulp::RepositoryExtension
26
+ VCR.insert_cassette('pulp_repository')
27
+ end
28
+
29
+ def teardown
30
+ VCR.eject_cassette
31
+ end
32
+
33
+ end
34
+
35
+ =begin
36
+ class TestPulpRepositoryCreate < MiniTest::Unit::TestCase
37
+ include TestPulpRepositoryBase
38
+
39
+ def teardown
40
+ RepositoryHelper.destroy_repo
41
+ super
42
+ end
43
+
44
+ def test_create
45
+ response = RepositoryHelper.create_repo
46
+ assert response.code == 201
47
+ assert response['id'] == RepositoryHelper.repo_id
48
+ end
49
+ end
50
+
51
+
52
+ class TestPulpRepositoryDelete < MiniTest::Unit::TestCase
53
+ include TestPulpRepositoryBase
54
+
55
+ def setup
56
+ super
57
+ RepositoryHelper.create_repo
58
+ end
59
+
60
+ def test_delete
61
+ response = @resource.delete(RepositoryHelper.repo_id)
62
+ assert response.code == 200
63
+ end
64
+
65
+ end
66
+
67
+
68
+ class TestPulpRepository < MiniTest::Unit::TestCase
69
+ include TestPulpRepositoryBase
70
+
71
+ def self.before_suite
72
+ RepositoryHelper.create_repo(:importer => true)
73
+ end
74
+
75
+ def self.after_suite
76
+ RepositoryHelper.destroy_repo
77
+ end
78
+
79
+ def test_repository_path
80
+ path = @resource.path
81
+ assert_match("repositories/", path)
82
+ end
83
+
84
+ def test_repository_path_with_id
85
+ path = @resource.path(RepositoryHelper.repo_id)
86
+ assert_match("repositories/#{RepositoryHelper.repo_id}", path)
87
+ end
88
+
89
+ def test_update
90
+ response = @resource.update(RepositoryHelper.repo_id, { :description => "updated_description_" + RepositoryHelper.repo_id })
91
+ assert response.code == 200
92
+ assert response["description"] == "updated_description_" + RepositoryHelper.repo_id
93
+ end
94
+
95
+ def test_retrieve
96
+ response = @resource.retrieve(RepositoryHelper.repo_id)
97
+ assert response.code == 200
98
+ assert response["display_name"] == RepositoryHelper.repo_id
99
+ end
100
+
101
+ def test_retrieve_with_details
102
+ response = @resource.retrieve(RepositoryHelper.repo_id, {:details => true})
103
+ assert response.code == 200
104
+ assert response.has_key?("distributors")
105
+ assert response.has_key?("importers")
106
+ end
107
+
108
+ def test_retrieve_all
109
+ response = @resource.retrieve_all()
110
+ assert response.code == 200
111
+ assert response.collect{ |repo| repo["display_name"] == RepositoryHelper.repo_id }.length > 0
112
+ end
113
+
114
+ def test_search
115
+ response = @resource.search({})
116
+ assert response.code == 200
117
+ assert response.collect{ |repo| repo["display_name"] == RepositoryHelper.repo_id }.length > 0
118
+ end
119
+
120
+ def test_associate_importer
121
+ response = @resource.associate_importer(RepositoryHelper.repo_id, "yum_importer", {})
122
+ assert response.code == 201
123
+ assert response['importer_type_id'] == "yum_importer"
124
+ end
125
+
126
+ def test_associate_distributor
127
+ distributor_config = {"relative_url" => "/", "http" => true, "https" => true}
128
+
129
+ response = @resource.associate_distributor(RepositoryHelper.repo_id, "yum_distributor", distributor_config)
130
+ assert response.code == 201
131
+ assert response['distributor_type_id'] == "yum_distributor"
132
+ end
133
+
134
+ end
135
+
136
+
137
+ class TestPulpRepositorySync < MiniTest::Unit::TestCase
138
+ include TestPulpRepositoryBase
139
+
140
+ def setup
141
+ super
142
+ VCR.eject_cassette
143
+ VCR.insert_cassette('pulp_repository_sync')
144
+ end
145
+
146
+ def teardown
147
+ RepositoryHelper.destroy_repo
148
+ super
149
+ end
150
+
151
+ def test_sync_repo
152
+ RepositoryHelper.create_repo
153
+ response = @resource.sync(RepositoryHelper.repo_id)
154
+ RepositoryHelper.task = response[0]
155
+
156
+ assert response.code == 202
157
+ assert response.length == 1
158
+ assert response[0]["tags"].include?('pulp:action:sync')
159
+ end
160
+
161
+ def test_sync_repo_with_yum_importer
162
+ RepositoryHelper.create_repo(:importer => true)
163
+ response = @resource.sync(RepositoryHelper.repo_id)
164
+ RepositoryHelper.task = response.first
165
+
166
+ assert response.code == 202
167
+ assert response.length == 1
168
+ assert response.first["tags"].include?('pulp:action:sync')
169
+ end
170
+ end
171
+ =end
172
+
173
+ class TestPulpRepositoryClone < MiniTest::Unit::TestCase
174
+ include TestPulpRepositoryBase
175
+
176
+ def setup
177
+ super
178
+ @clone_name = RepositoryHelper.repo_id + "_clone"
179
+ RepositoryHelper.destroy_repo(@clone_name)
180
+ RepositoryHelper.destroy_repo
181
+ RepositoryHelper.create_and_sync_repo(:importer => true)
182
+ @extension.create_with_importer(@clone_name, "yum_importer", {})
183
+ end
184
+
185
+ def teardown
186
+ RepositoryHelper.destroy_repo(@clone_name)
187
+ RepositoryHelper.destroy_repo
188
+ super
189
+ end
190
+
191
+ def test_unit_copy
192
+ response = @resource.unit_copy(@clone_name, RepositoryHelper.repo_id)
193
+ RepositoryHelper.task = response
194
+ assert response.code == 202
195
+ assert response['tags'].include?('pulp:action:associate')
196
+ end
197
+
198
+ end
199
+
200
+
201
+ =begin
202
+
203
+ def test_discovery
204
+ response = @resource.start_discovery(RepositoryHelper.repo_url, 'yum')
205
+ assert response.length > 0
206
+ end
207
+
208
+ def test_all
209
+ response = @resource.all()
210
+ assert response.length > 0
211
+ assert response.select { |r| r["name"] == RepositoryHelper.repo_id }.length > 0
212
+ end
213
+
214
+ def test_update_schedule
215
+ response = @resource.update_schedule(RepositoryHelper.repo_id, "R1/" << Time.now.advance(:years => 1).iso8601 << "/P1D")
216
+ assert JSON.parse(response)["id"] == RepositoryHelper.repo_id
217
+ @resource.delete_schedule(RepositoryHelper.repo_id)
218
+ end
219
+
220
+ def test_delete_schedule
221
+ @resource.update_schedule(RepositoryHelper.repo_id, "R1/" << Time.now.advance(:years => 1).iso8601 << "/P1D")
222
+ response = @resource.delete_schedule(RepositoryHelper.repo_id)
223
+ assert JSON.parse(response)["id"] == RepositoryHelper.repo_id
224
+ end
225
+
226
+ def test_add_filters
227
+ response = @resource.add_filters(RepositoryHelper.repo_id, [FilterHelper.filter_id])
228
+ assert response == "true"
229
+ end
230
+
231
+ def test_remove_filters
232
+ response = @resource.remove_filters(RepositoryHelper.repo_id, [FilterHelper.filter_id])
233
+ assert response == "true"
234
+ end
235
+
236
+ def test_destroy
237
+ response = @resource.destroy(RepositoryHelper.repo_id)
238
+ assert response == 202
239
+ end
240
+ end
241
+
242
+
243
+ class TestPulpRepositoryRequiresSync < MiniTest::Unit::TestCase
244
+ include TestPulpRepositoryBase
245
+
246
+ def self.before_suite
247
+ RepositoryHelper.create_and_sync_repo
248
+ end
249
+
250
+ def self.after_suite
251
+ RepositoryHelper.destroy_repo
252
+ end
253
+
254
+ def test_packages
255
+ response = @resource.packages(RepositoryHelper.repo_id)
256
+ assert response.length > 0
257
+ end
258
+
259
+ def test_packages_by_name
260
+ response = @resource.packages_by_name(RepositoryHelper.repo_id, "cheetah")
261
+ assert response.length > 0
262
+ assert response.select { |r| r["name"] == "cheetah" }.length > 0
263
+ end
264
+
265
+ def test_packages_by_nvre
266
+ response = @resource.packages_by_nvre(RepositoryHelper.repo_id, "cheetah", "0.3", "0.8", "")
267
+ assert response.length > 0
268
+ assert response.select { |r| r["name"] == "cheetah" }.length > 0
269
+ end
270
+
271
+ def test_errata
272
+ response = @resource.errata(RepositoryHelper.repo_id)
273
+ assert response.length > 0
274
+ end
275
+
276
+ def test_errata_with_filter
277
+ response = @resource.errata(RepositoryHelper.repo_id, { :type => 'security' })
278
+ assert response.length > 0
279
+ assert response.select { |errata| errata['id'] == "RHEA-2010:0002" }.length > 0
280
+ end
281
+
282
+ def test_distributions
283
+ response = @resource.distributions(RepositoryHelper.repo_id)
284
+ assert response.kind_of?(Array)
285
+ end
286
+
287
+ def test_sync_history
288
+ response = @resource.sync_history(RepositoryHelper.repo_id)
289
+ assert response.length > 0
290
+ end
291
+
292
+ def test_add_packages
293
+ response = @resource.add_packages(RepositoryHelper.repo_id, [])
294
+ assert response == "[[], 0]"
295
+ end
296
+
297
+ def test_add_errata
298
+ response = @resource.add_errata(RepositoryHelper.repo_id, ["RHEA-2010:0002"])
299
+ assert response == "[]"
300
+ end
301
+
302
+ def test_add_distribution
303
+ response = @resource.add_distribution(RepositoryHelper.repo_id, "ks-Test Family-TestVariant-16-x86_64")
304
+ assert response == "true"
305
+ end
306
+ end
307
+ =end