runcible 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.
- data/.gitignore +18 -0
- data/Gemfile +19 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +37 -0
- data/lib/runcible.rb +25 -0
- data/lib/runcible/base.rb +113 -0
- data/lib/runcible/extensions/repository.rb +67 -0
- data/lib/runcible/oauth_setup.rb +29 -0
- data/lib/runcible/resources/repository.rb +82 -0
- data/lib/runcible/resources/role.rb +46 -0
- data/lib/runcible/resources/task.rb +49 -0
- data/lib/runcible/resources/user.rb +50 -0
- data/lib/runcible/version.rb +3 -0
- data/rel-eng/packages/.readme +3 -0
- data/rel-eng/tito.props +5 -0
- data/runcible.gemspec +17 -0
- data/runcible.spec +48 -0
- data/test/.gitkeep +0 -0
- data/test/integration/extensions/repository_test.rb +117 -0
- data/test/integration/fixtures/repositories/zoo5/.treeinfo +12 -0
- data/test/integration/fixtures/repositories/zoo5/CHANGESET +11 -0
- data/test/integration/fixtures/repositories/zoo5/PULP_MANIFEST +1 -0
- data/test/integration/fixtures/repositories/zoo5/cheetah-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/create.sh +20 -0
- data/test/integration/fixtures/repositories/zoo5/elephant-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/empty.iso +0 -0
- data/test/integration/fixtures/repositories/zoo5/giraffe-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/images/test1.img +0 -0
- data/test/integration/fixtures/repositories/zoo5/images/test2.img +0 -0
- data/test/integration/fixtures/repositories/zoo5/lion-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/monkey-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/penguin-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/06661e2a9839cf0beebcf409410ca4f93c09081f4e772fd0d03e1faf62705a11-comps.xml +39 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/0c4d57a68f9a3b13dabc6f8b01ca8958aa796167cececee04717edfc26d02f2d-other.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/298ce23f48b3613e030d19f3d9c2ff2df31c2f08479bdf94cebb87c208e48c0e-filelists.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/32c0e38317aade0c057b173ff62344e912e1bd650409c6ac31aecee78e3413af-comps.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/34d954906c7ce7aa2254e24d7be0a9049e0a2f436add023ca056123a2d48e30e-updateinfo.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/63aedd074d9f0daf7c6be8c61f91d76a962bb6ceda86b9abd2140f154c320fa2-other.sqlite.bz2 +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/69d65cdebffc6199d3adb3e38b06ca9abaae6c1c7366805099987b28f182178d-filelists.sqlite.bz2 +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/799241a518a4a6b11a68f8e6fbdb719875f87832f60accc0851ced0d6a0497c6-updateinfo.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/a4ea9fcdce31dc8673c7a9ba66c086bd6a16e1eff717e3896dd1cac444a1423c-primary.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/fb9b9508e148368d0edf7e03dc905b343937fd958e6531cce6380933d18c3455-primary.sqlite.bz2 +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/repomd.xml +75 -0
- data/test/integration/fixtures/repositories/zoo5/squirrel-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/updateinfo.xml +26 -0
- data/test/integration/fixtures/repositories/zoo5/walrus-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/vcr_cassettes/extensions/pulp_repository_extensions.yml +137 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_consumer.yml +1529 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_consumer_group.yml +430 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_consumer_helper.yml +120 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_distribution.yml +77 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_errata.yml +77 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_filter.yml +233 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_filter_helper.yml +81 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_package.yml +155 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_package_group.yml +40 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_package_group_category.yml +40 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_ping.yml +40 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_repository.yml +1196 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_repository_helper.yml +8659 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_repository_sync.yml +215 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_role.yml +133 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_roles.yml +120 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_task.yml +943 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_user.yml +288 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_user_helper.yml +195 -0
- data/test/integration/resources/helpers/consumer_helper.rb +49 -0
- data/test/integration/resources/helpers/filter_helper.rb +44 -0
- data/test/integration/resources/helpers/repository_helper.rb +127 -0
- data/test/integration/resources/pulp_consumer_group_test.rb +182 -0
- data/test/integration/resources/pulp_consumer_test.rb +200 -0
- data/test/integration/resources/pulp_distribution_test.rb +55 -0
- data/test/integration/resources/pulp_errata_test.rb +60 -0
- data/test/integration/resources/pulp_filter_test.rb +92 -0
- data/test/integration/resources/pulp_package_group_category_test.rb +55 -0
- data/test/integration/resources/pulp_package_group_test.rb +56 -0
- data/test/integration/resources/pulp_package_test.rb +79 -0
- data/test/integration/resources/pulp_ping_test.rb +31 -0
- data/test/integration/resources/pulp_repository_test.rb +307 -0
- data/test/integration/resources/pulp_role_test.rb +62 -0
- data/test/integration/resources/pulp_task_test.rb +79 -0
- data/test/integration/resources/pulp_user_test.rb +105 -0
- data/test/integration/test_runner.rb +113 -0
- data/test/integration/vcr_setup.rb +22 -0
- data/test/unit/test_base.rb +62 -0
- metadata +218 -0
|
@@ -0,0 +1,62 @@
|
|
|
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 './lib/runcible/resources/user'
|
|
16
|
+
require './lib/runcible/resources/role'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class TestPulpRoles < MiniTest::Unit::TestCase
|
|
20
|
+
def setup
|
|
21
|
+
@username = "integration_test_user"
|
|
22
|
+
@role_name = "super-users"
|
|
23
|
+
@resource = Runcible::Pulp::Role
|
|
24
|
+
|
|
25
|
+
VCR.use_cassette('pulp_user') do
|
|
26
|
+
Runcible::Pulp::User.create(@username)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
VCR.insert_cassette('pulp_role')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def teardown
|
|
33
|
+
VCR.use_cassette('pulp_user') do
|
|
34
|
+
Runcible::Pulp::User.delete(@username)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
VCR.eject_cassette
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_path_without_role_name
|
|
41
|
+
path = @resource.path
|
|
42
|
+
assert_match("roles/", path)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_path_with_role_name
|
|
46
|
+
path = @resource.path(@role_name)
|
|
47
|
+
assert_match("roles/#{@role_name}", path)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_add
|
|
51
|
+
response = @resource.add(@role_name, @username)
|
|
52
|
+
assert response.code == 200
|
|
53
|
+
@resource.remove(@role_name, @username)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_remove
|
|
57
|
+
@resource.add(@role_name, @username)
|
|
58
|
+
response = @resource.remove(@role_name, @username)
|
|
59
|
+
assert response.code == 200
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
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
|
+
|
|
15
|
+
require './test/integration/resources/helpers/repository_helper'
|
|
16
|
+
require './lib/runcible/resources/task'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
module TestPulpTaskBase
|
|
20
|
+
include RepositoryHelper
|
|
21
|
+
|
|
22
|
+
def setup
|
|
23
|
+
@resource = Runcible::Pulp::Task
|
|
24
|
+
VCR.insert_cassette('pulp_task')
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def teardown
|
|
28
|
+
VCR.eject_cassette
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class TestPulpTask < MiniTest::Unit::TestCase
|
|
35
|
+
include TestPulpTaskBase
|
|
36
|
+
|
|
37
|
+
def setup
|
|
38
|
+
super
|
|
39
|
+
RepositoryHelper.create_repo(:importer => true)
|
|
40
|
+
RepositoryHelper.sync_repo(false)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def teardown
|
|
44
|
+
super
|
|
45
|
+
RepositoryHelper.destroy_repo
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_path
|
|
49
|
+
path = @resource.path
|
|
50
|
+
assert_match("tasks/", path)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_path_with_task_id
|
|
54
|
+
path = @resource.path(RepositoryHelper.task['task_id'])
|
|
55
|
+
assert_match("tasks/#{RepositoryHelper.task['task_id']}/", path)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_poll
|
|
59
|
+
response = @resource.poll(RepositoryHelper.task['task_id'])
|
|
60
|
+
assert response.code == 200
|
|
61
|
+
assert response['task_id'] == RepositoryHelper.task['task_id']
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_list
|
|
65
|
+
response = @resource.list
|
|
66
|
+
assert response.code == 200
|
|
67
|
+
assert response.length > 0
|
|
68
|
+
#assert response.first['task_id'] == RepositoryHelper.task['task_id']
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
=begin
|
|
72
|
+
#TODO: Needs more reliable testable scenario - scheduled sync in the future?
|
|
73
|
+
def test_cancel
|
|
74
|
+
response = @resource.cancel(RepositoryHelper.task['task_id'])
|
|
75
|
+
assert response.code == 200
|
|
76
|
+
end
|
|
77
|
+
=end
|
|
78
|
+
|
|
79
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
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 './lib/runcible/resources/user'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
module TestPulpUserBase
|
|
19
|
+
def setup
|
|
20
|
+
VCR.insert_cassette('pulp_user')
|
|
21
|
+
@username = "integration_test_user"
|
|
22
|
+
@resource = Runcible::Pulp::User
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def teardown
|
|
26
|
+
VCR.eject_cassette
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class TestPulpUserCreate < MiniTest::Unit::TestCase
|
|
31
|
+
include TestPulpUserBase
|
|
32
|
+
|
|
33
|
+
def teardown
|
|
34
|
+
super
|
|
35
|
+
VCR.use_cassette('pulp_user_helper') do
|
|
36
|
+
begin
|
|
37
|
+
@resource.retrieve(@username)
|
|
38
|
+
@resource.delete(@username)
|
|
39
|
+
rescue RestClient::ResourceNotFound => e
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_create
|
|
45
|
+
response = @resource.create(@username)
|
|
46
|
+
assert response.code == 201
|
|
47
|
+
assert response['login'] == @username
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_create_with_name_and_password
|
|
51
|
+
response = @resource.create(@username, {:name => @username, :password => "integration_test_password"})
|
|
52
|
+
assert response.code == 201
|
|
53
|
+
assert response['name'] == @username
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class TestPulpUser < MiniTest::Unit::TestCase
|
|
60
|
+
include TestPulpUserBase
|
|
61
|
+
|
|
62
|
+
def setup
|
|
63
|
+
super
|
|
64
|
+
VCR.use_cassette('pulp_user_helper') do
|
|
65
|
+
begin
|
|
66
|
+
@resource.retrieve(@username)
|
|
67
|
+
rescue RestClient::ResourceNotFound => e
|
|
68
|
+
@resource.create(@username)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def teardown
|
|
74
|
+
super
|
|
75
|
+
VCR.use_cassette('pulp_user_helper') do
|
|
76
|
+
begin
|
|
77
|
+
@resource.retrieve(@username)
|
|
78
|
+
@resource.delete(@username)
|
|
79
|
+
rescue RestClient::ResourceNotFound => e
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_path_without_username
|
|
85
|
+
path = @resource.path
|
|
86
|
+
assert_match("users/", path)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_path_with_username
|
|
90
|
+
path = @resource.path(@username)
|
|
91
|
+
assert_match("users/#{@username}", path)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_retrieve
|
|
95
|
+
response = @resource.retrieve(@username)
|
|
96
|
+
assert response.code == 200
|
|
97
|
+
assert response["login"] == @username
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def test_delete
|
|
101
|
+
response = @resource.delete(@username)
|
|
102
|
+
assert response.code == 200
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
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/unit'
|
|
14
|
+
require 'minitest/autorun'
|
|
15
|
+
require 'inifile'
|
|
16
|
+
|
|
17
|
+
require 'test/integration/vcr_setup'
|
|
18
|
+
require 'lib/runcible/base'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class CustomMiniTestRunner
|
|
22
|
+
class Unit < MiniTest::Unit
|
|
23
|
+
|
|
24
|
+
def before_suites
|
|
25
|
+
# code to run before the first test
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def after_suites
|
|
29
|
+
# code to run after the last test
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def _run_suites(suites, type)
|
|
33
|
+
begin
|
|
34
|
+
before_suites
|
|
35
|
+
super(suites, type)
|
|
36
|
+
ensure
|
|
37
|
+
after_suites
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def _run_suite(suite, type)
|
|
42
|
+
begin
|
|
43
|
+
suite.before_suite if suite.respond_to?(:before_suite)
|
|
44
|
+
super(suite, type)
|
|
45
|
+
ensure
|
|
46
|
+
suite.after_suite if suite.respond_to?(:after_suite)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class PulpMiniTestRunner
|
|
55
|
+
|
|
56
|
+
def run_tests(options={})
|
|
57
|
+
mode = options[:mode] || "recorded"
|
|
58
|
+
test_name = options[:test_name] || nil
|
|
59
|
+
auth_type = options[:auth_type] || "basic"
|
|
60
|
+
|
|
61
|
+
MiniTest::Unit.runner = CustomMiniTestRunner::Unit.new
|
|
62
|
+
|
|
63
|
+
set_runcible_config(auth_type)
|
|
64
|
+
set_vcr_config(mode)
|
|
65
|
+
|
|
66
|
+
if test_name
|
|
67
|
+
require test_name
|
|
68
|
+
else
|
|
69
|
+
Dir["test/integration/resources/*_test.rb"].each {|file| require file }
|
|
70
|
+
Dir["test/integration/extensions/*_test.rb"].each {|file| require file }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def set_runcible_config(auth_type)
|
|
75
|
+
if auth_type == "basic"
|
|
76
|
+
Runcible::Base.config = {}
|
|
77
|
+
|
|
78
|
+
File.open('/etc/pulp/server.conf') do |f|
|
|
79
|
+
f.each_line do |line|
|
|
80
|
+
if line.start_with?('default_password')
|
|
81
|
+
Runcible::Base.config[:password] = line.split(':')[1].strip
|
|
82
|
+
elsif line.start_with?('default_login')
|
|
83
|
+
Runcible::Base.config[:user] = line.split(':')[1].strip
|
|
84
|
+
elsif line.start_with?('server_name')
|
|
85
|
+
Runcible::Base.config[:url] = 'https://' + line.split(':')[1].chomp.strip
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
elsif auth_type == "oauth"
|
|
90
|
+
Runcible::Base.config = { :oauth => {} }
|
|
91
|
+
|
|
92
|
+
File.open('/etc/pulp/server.conf') do |f|
|
|
93
|
+
f.each_line do |line|
|
|
94
|
+
if line.start_with?('oauth_secret')
|
|
95
|
+
Runcible::Base.config[:oauth][:oauth_secret] = line.split(':')[1].strip
|
|
96
|
+
elsif line.start_with?('oauth_key')
|
|
97
|
+
Runcible::Base.config[:oauth][:oauth_key] = line.split(':')[1].strip
|
|
98
|
+
elsif line.start_with?('server_name')
|
|
99
|
+
Runcible::Base.config[:url] = 'https://' + line.split(':')[1].chomp.strip
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def set_vcr_config(mode)
|
|
107
|
+
if mode == "live"
|
|
108
|
+
configure_vcr(:all)
|
|
109
|
+
else
|
|
110
|
+
configure_vcr(:new_episodes)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
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 'vcr'
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def configure_vcr(record_mode=:all)
|
|
17
|
+
VCR.configure do |c|
|
|
18
|
+
c.cassette_library_dir = 'test/integration/fixtures/vcr_cassettes'
|
|
19
|
+
c.hook_into :webmock
|
|
20
|
+
c.default_cassette_options = { :record => record_mode } #forcing all requests to Pulp currently
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Copyright (c) 2012 Eric D Helms
|
|
2
|
+
#
|
|
3
|
+
# MIT License
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
# a copy of this software and associated documentation files (the
|
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
# the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be
|
|
14
|
+
# included in all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
require 'rubygems'
|
|
25
|
+
require 'minitest/autorun'
|
|
26
|
+
require 'minitest/mock'
|
|
27
|
+
require 'ruby-debug'
|
|
28
|
+
require './lib/runcible/base'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class TestBase < MiniTest::Unit::TestCase
|
|
32
|
+
def setup
|
|
33
|
+
Runcible::Base.config = {
|
|
34
|
+
:base_url => "http://localhost/",
|
|
35
|
+
:user => "test_user",
|
|
36
|
+
:password => "test_password",
|
|
37
|
+
:oauth => "test_oauth",
|
|
38
|
+
:headers => { :content_type => 'application/json',
|
|
39
|
+
:accept => 'application/json' }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@base = Runcible::Base.new
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_config
|
|
46
|
+
assert !Runcible::Base.config.nil?
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_process_response_returns_hash
|
|
50
|
+
json = { :a => "test", :b => "data" }.to_json
|
|
51
|
+
data = @base.process_response(json)
|
|
52
|
+
|
|
53
|
+
assert data["a"] = "test"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_process_response_returns_string
|
|
57
|
+
string = "true"
|
|
58
|
+
data = @base.process_response(string)
|
|
59
|
+
|
|
60
|
+
assert data = "true"
|
|
61
|
+
end
|
|
62
|
+
end
|