right_scraper 3.2.6 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/lib/right_scraper.rb +16 -34
  3. data/lib/right_scraper/builders.rb +32 -0
  4. data/lib/right_scraper/builders/base.rb +19 -20
  5. data/lib/right_scraper/builders/filesystem.rb +8 -6
  6. data/lib/right_scraper/builders/union.rb +4 -1
  7. data/lib/right_scraper/loggers.rb +31 -0
  8. data/lib/right_scraper/loggers/base.rb +113 -0
  9. data/lib/right_scraper/loggers/default.rb +98 -0
  10. data/lib/right_scraper/{scraper.rb → main.rb} +53 -9
  11. data/lib/right_scraper/processes.rb +33 -0
  12. data/lib/right_scraper/processes/shell.rb +227 -0
  13. data/lib/right_scraper/processes/{ssh.rb → ssh_agent.rb} +4 -0
  14. data/lib/right_scraper/processes/svn_client.rb +117 -0
  15. data/lib/right_scraper/processes/warden.rb +358 -0
  16. data/lib/right_scraper/registered_base.rb +154 -0
  17. data/lib/right_scraper/repositories.rb +33 -0
  18. data/lib/right_scraper/repositories/base.rb +271 -232
  19. data/lib/right_scraper/repositories/download.rb +8 -6
  20. data/lib/right_scraper/repositories/git.rb +8 -9
  21. data/lib/right_scraper/repositories/svn.rb +8 -8
  22. data/lib/right_scraper/resources.rb +32 -0
  23. data/lib/right_scraper/resources/base.rb +5 -1
  24. data/lib/right_scraper/resources/cookbook.rb +34 -27
  25. data/lib/right_scraper/resources/workflow.rb +27 -28
  26. data/lib/right_scraper/retrievers.rb +34 -0
  27. data/lib/right_scraper/retrievers/base.rb +80 -84
  28. data/lib/right_scraper/retrievers/checkout_base.rb +178 -0
  29. data/lib/right_scraper/retrievers/download.rb +125 -117
  30. data/lib/right_scraper/retrievers/git.rb +377 -223
  31. data/lib/right_scraper/retrievers/svn.rb +102 -62
  32. data/lib/right_scraper/scanners.rb +37 -0
  33. data/lib/right_scraper/scanners/base.rb +77 -80
  34. data/lib/right_scraper/scanners/cookbook_manifest.rb +31 -30
  35. data/lib/right_scraper/scanners/cookbook_metadata.rb +380 -35
  36. data/lib/right_scraper/scanners/cookbook_s3_upload.rb +56 -53
  37. data/lib/right_scraper/scanners/union.rb +61 -58
  38. data/lib/right_scraper/scanners/workflow_manifest.rb +55 -54
  39. data/lib/right_scraper/scanners/workflow_metadata.rb +41 -39
  40. data/lib/right_scraper/scanners/workflow_s3_upload.rb +59 -55
  41. data/lib/right_scraper/scrapers.rb +32 -0
  42. data/lib/right_scraper/scrapers/base.rb +217 -205
  43. data/lib/right_scraper/scrapers/cookbook.rb +42 -40
  44. data/lib/right_scraper/scrapers/workflow.rb +57 -58
  45. data/lib/right_scraper/version.rb +3 -0
  46. data/right_scraper.gemspec +12 -16
  47. metadata +57 -163
  48. data/Gemfile +0 -15
  49. data/Rakefile +0 -89
  50. data/lib/right_scraper/logger.rb +0 -107
  51. data/lib/right_scraper/loggers/noisy.rb +0 -85
  52. data/lib/right_scraper/repositories/mock.rb +0 -70
  53. data/lib/right_scraper/retrievers/checkout.rb +0 -79
  54. data/lib/right_scraper/scraper_logger.rb +0 -66
  55. data/lib/right_scraper/svn_client.rb +0 -164
  56. data/right_scraper.rconf +0 -13
  57. data/spec/builder_spec.rb +0 -50
  58. data/spec/cookbook_helper.rb +0 -73
  59. data/spec/cookbook_manifest_spec.rb +0 -93
  60. data/spec/cookbook_s3_upload_spec.rb +0 -159
  61. data/spec/download/download_retriever_spec.rb +0 -118
  62. data/spec/download/download_retriever_spec_helper.rb +0 -72
  63. data/spec/download/download_spec.rb +0 -128
  64. data/spec/download/multi_dir_spec.rb +0 -106
  65. data/spec/download/multi_dir_spec_helper.rb +0 -40
  66. data/spec/git/cookbook_spec.rb +0 -165
  67. data/spec/git/demokey +0 -27
  68. data/spec/git/demokey.pub +0 -1
  69. data/spec/git/password_key +0 -30
  70. data/spec/git/password_key.pub +0 -1
  71. data/spec/git/repository_spec.rb +0 -110
  72. data/spec/git/retriever_spec.rb +0 -553
  73. data/spec/git/retriever_spec_helper.rb +0 -112
  74. data/spec/git/scraper_spec.rb +0 -151
  75. data/spec/git/ssh_spec.rb +0 -174
  76. data/spec/git/url_spec.rb +0 -103
  77. data/spec/logger_spec.rb +0 -185
  78. data/spec/repository_spec.rb +0 -111
  79. data/spec/retriever_spec_helper.rb +0 -146
  80. data/spec/scanner_spec.rb +0 -61
  81. data/spec/scraper_helper.rb +0 -88
  82. data/spec/scraper_spec.rb +0 -147
  83. data/spec/spec_helper.rb +0 -185
  84. data/spec/svn/cookbook_spec.rb +0 -96
  85. data/spec/svn/multi_svn_spec.rb +0 -64
  86. data/spec/svn/multi_svn_spec_helper.rb +0 -40
  87. data/spec/svn/repository_spec.rb +0 -72
  88. data/spec/svn/retriever_spec.rb +0 -266
  89. data/spec/svn/scraper_spec.rb +0 -90
  90. data/spec/svn/svn_retriever_spec_helper.rb +0 -90
  91. data/spec/svn/url_spec.rb +0 -47
  92. data/spec/url_spec.rb +0 -164
@@ -1,159 +0,0 @@
1
- #--
2
- # Copyright: Copyright (c) 2010-2011 RightScale, Inc.
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # 'Software'), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
-
24
- require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
25
- require 'tmpdir'
26
- require 'digest/sha1'
27
-
28
- describe RightScraper::Scanners::CookbookS3Upload do
29
- include RightScraper::SpecHelpers::DevelopmentModeEnvironment
30
-
31
- include RightScraper::SpecHelpers
32
-
33
- # Create download repository following given layout
34
- # Update @repo_path with path to repository
35
- # Delete any previously created repo
36
- def setup_download_repo
37
- @tmpdir = Dir.mktmpdir
38
- @download_repo_path = File.join(@tmpdir, "download")
39
- @repo_path = File.join(@tmpdir, "repo")
40
- @repo_content = [ { 'folder1' => [ 'file2', 'file3' ] }, { 'folder2' => [ { 'folder3' => [ 'file4' ] } ] }, 'file1' ]
41
- create_cookbook(@download_repo_path, @repo_content)
42
- @download_file = File.join(@tmpdir, "file.tar")
43
- Dir.chdir(@download_repo_path) do
44
- res, status = exec("tar cf \"#{@download_file}\" *")
45
- raise "Failed to create tarball: #{res}" unless status.success?
46
- end
47
- end
48
-
49
- # Cleanup after ourselves
50
- def delete_download_repo
51
- FileUtils.remove_entry_secure @tmpdir unless @tmpdir.nil?
52
- end
53
-
54
- before(:all) do
55
- @scraperclass = RightScraper::Scrapers::Cookbook
56
- end
57
-
58
- before(:each) do
59
- pending "Not run unless AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY set" unless
60
- ENV['AWS_ACCESS_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY']
61
- end
62
-
63
- context "given a bucket that doesn't exist" do
64
- before(:each) do
65
- setup_download_repo
66
- end
67
-
68
- after(:each) do
69
- delete_download_repo
70
- end
71
-
72
- before(:each) do
73
- @repo = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
74
- :repo_type => :download,
75
- :url => "file:///#{@download_file}")
76
- @s3 = RightAws::S3.new(aws_access_key_id=ENV['AWS_ACCESS_KEY_ID'],
77
- aws_secret_access_key=ENV['AWS_SECRET_ACCESS_KEY'],
78
- :logger => RightScraper::Logger.new)
79
- FileUtils.rm_rf(RightScraper::Retrievers::Base.repo_dir(@repo_path, @repo))
80
- end
81
-
82
- it 'should raise an exception immediately' do
83
- bucket_name = 'this-bucket-does-not-exist'
84
- @s3.bucket(bucket_name).should be_nil
85
- lambda {
86
- @scraper = @scraperclass.new(:repository => @repo,
87
- :repo_dir => @download_repo_path,
88
- :scanners => [RightScraper::Scanners::CookbookMetadata,
89
- RightScraper::Scanners::CookbookManifest,
90
- RightScraper::Scanners::CookbookS3Upload],
91
- :s3_key => ENV['AWS_ACCESS_KEY_ID'],
92
- :s3_secret => ENV['AWS_SECRET_ACCESS_KEY'],
93
- :s3_bucket => bucket_name,
94
- :max_bytes => 1024**2,
95
- :max_seconds => 20)
96
- }.should raise_exception(/Need an actual, existing S3 bucket!/)
97
- end
98
- end
99
-
100
- context 'given a download repository with the S3UploadScanner' do
101
- before(:each) do
102
- setup_download_repo
103
- end
104
-
105
- before(:each) do
106
- @repo = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
107
- :repo_type => :download,
108
- :url => "file:///#{@download_file}")
109
- bucket_name = 'com.rightscale.test.20100823'
110
- @scraper = @scraperclass.new(:repository => @repo,
111
- :repo_dir => @download_repo_path,
112
- :scanners => [RightScraper::Scanners::CookbookMetadata,
113
- RightScraper::Scanners::CookbookManifest,
114
- RightScraper::Scanners::CookbookS3Upload],
115
- :s3_key => ENV['AWS_ACCESS_KEY_ID'],
116
- :s3_secret => ENV['AWS_SECRET_ACCESS_KEY'],
117
- :s3_bucket => bucket_name,
118
- :max_bytes => 1024**2,
119
- :max_seconds => 20)
120
- s3 = RightAws::S3.new(aws_access_key_id=ENV['AWS_ACCESS_KEY_ID'],
121
- aws_secret_access_key=ENV['AWS_SECRET_ACCESS_KEY'],
122
- :logger => RightScraper::Logger.new)
123
-
124
- # create=true is prone to the too-many-buckets error even when the bucket
125
- # already exists. since the bucket always exists for the test account
126
- # there is no need to try creating it programmatically and fail specs.
127
- @bucket = s3.bucket(bucket_name, create=false)
128
- FileUtils.rm_rf(RightScraper::Retrievers::Base.repo_dir(@repo_path, @repo))
129
- end
130
-
131
- after(:each) do
132
- delete_download_repo
133
- end
134
-
135
- context 'that has scraped' do
136
- before(:each) do
137
- @cookbook = @scraper.next_resource
138
- @cookbook.should_not be_nil
139
- end
140
-
141
- it 'the cookbook should exist' do
142
- s3cookbook = @bucket.get(File.join('Cooks', @cookbook.resource_hash))
143
- s3cookbook.should_not be_nil
144
- ::Digest::MD5.hexdigest(s3cookbook).should == @cookbook.resource_hash
145
- s3cookbook.should_not == ::RightScraper::Resources::Cookbook::EMPTY_MANIFEST_JSON
146
- hash = JSON.parse(s3cookbook)
147
- hash["manifest"].should == @cookbook.manifest
148
- end
149
-
150
- it 'every file in the manifest should exist' do
151
- @cookbook.manifest.each do |key, value|
152
- file = @bucket.get(File.join('Files', value))
153
- file.should_not be_nil
154
- value.should == Digest::MD5.hexdigest(file)
155
- end
156
- end
157
- end
158
- end
159
- end
@@ -1,118 +0,0 @@
1
- #--
2
- # Copyright: Copyright (c) 2010-2011 RightScale, Inc.
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # 'Software'), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
-
24
- require File.expand_path(File.join(File.dirname(__FILE__), 'download_retriever_spec_helper'))
25
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'scraper_helper'))
26
-
27
- describe RightScraper::Retrievers::Download do
28
- include RightScraper::SpecHelpers::DevelopmentModeEnvironment
29
-
30
- include RightScraper::ScraperHelper
31
- include RightScraper::SpecHelpers
32
-
33
- before(:each) do
34
- @helper = RightScraper::DownloadRetrieverSpecHelper.new
35
- @repo = @helper.repo
36
- @retriever = @repo.retriever(:max_bytes => 1024**2, :max_seconds => 20, :basedir => @helper.download_repo_path)
37
- end
38
-
39
- after(:each) do
40
- @helper.close unless @helper.nil?
41
- @helper = nil
42
- end
43
-
44
- it 'should not initially have a tag' do
45
- @repo.tag.should be_nil
46
- end
47
-
48
- context 'given a password protected repository' do
49
- before(:each) do
50
- pending "Not run unless REMOTE_USER and REMOTE_PASSWORD set" unless ENV['REMOTE_USER'] && ENV['REMOTE_PASSWORD']
51
- url = 'https://wush.net/svn/rightscale/cookbooks_test/cookbooks/app_rails.tar.gz'
52
- @repo.url = url
53
- @repo.display_name = 'wush'
54
- end
55
-
56
- it 'should scrape' do
57
- @retriever.retrieve
58
- scraper = RightScraper::Scrapers::Base.scraper(:kind => :cookbook,
59
- :ignorable_paths => @retriever.ignorable_paths,
60
- :repo_dir => @retriever.repo_dir,
61
- :repository => @retriever.repository)
62
- cookbook = scraper.next_resource
63
- cookbook.should_not be_nil
64
- cookbook.metadata.should_not be_nil
65
- cookbook.metadata["name"].should == "app_rails"
66
- cookbook.repository.tag.should_not be_nil
67
- end
68
- end
69
-
70
- context 'given a download repository' do
71
- before(:each) do
72
- @download_file = @helper.download_file
73
- end
74
-
75
- def get_scraper
76
- @retriever.retrieve
77
- RightScraper::Scrapers::Base.scraper(:kind => :cookbook,
78
- :ignorable_paths => @retriever.ignorable_paths,
79
- :repo_dir => @retriever.repo_dir,
80
- :repository => @retriever.repository)
81
- end
82
-
83
- it 'should only return one cookbook' do
84
- scraper = get_scraper
85
- scraper.next_resource
86
- scraper.next_resource.should == nil
87
- end
88
-
89
- it 'should scrape' do
90
- scraper = get_scraper
91
- @helper.check_resource(scraper.next_resource, @download_file, @repo)
92
- end
93
-
94
- it 'should scrape a gzipped tarball' do
95
- res, status = exec("gzip -c #{@download_file} > #{@download_file}.gz")
96
- raise "Failed to gzip tarball: #{res}" unless status.success?
97
- @repo.url += ".gz"
98
- scraper = get_scraper
99
- begin
100
- @helper.check_resource(scraper.next_resource, @download_file + ".gz", @repo)
101
- ensure
102
- File.unlink(@download_file + ".gz")
103
- end
104
- end
105
-
106
- it 'should scrape a bzipped tarball' do
107
- res, status = exec("bzip2 -c #{@download_file} > #{@download_file}.bz2")
108
- raise "Failed to bzip tarball: #{res}" unless status.success?
109
- @repo.url += ".bz2"
110
- scraper = get_scraper
111
- begin
112
- @helper.check_resource(scraper.next_resource, @download_file + ".bz2", @repo)
113
- ensure
114
- File.unlink(@download_file + ".bz2")
115
- end
116
- end
117
- end
118
- end
@@ -1,72 +0,0 @@
1
- #--
2
- # Copyright: Copyright (c) 2010-2011 RightScale, Inc.
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # 'Software'), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
-
24
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'retriever_spec_helper'))
25
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'right_scraper'))
26
-
27
- module RightScraper
28
- class DownloadRetrieverSpecHelper < RetrieverSpecHelper
29
- def download_repo_path
30
- File.join(@tmpdir, "download")
31
- end
32
-
33
- attr_reader :download_file
34
-
35
- def repo
36
- RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
37
- :repo_type => :download,
38
- :url => "file://#{@download_file}",
39
- :first_credential => ENV['REMOTE_USER'],
40
- :second_credential => ENV['REMOTE_PASSWORD'])
41
- end
42
-
43
- # Create download repository following given layout
44
- # Update @repo_path with path to repository
45
- # Delete any previously created repo
46
- def initialize
47
- super
48
- @download_repo_path = File.join(@tmpdir, "download")
49
- make_cookbooks
50
- @download_file = File.join(@tmpdir, "file.tar")
51
- Dir.chdir(download_repo_path) do
52
- res, status = exec("tar cf \"#{@download_file}\" *")
53
- raise "Failed to create tarball: #{res}" unless status.success?
54
- end
55
- end
56
-
57
- # Cookbook creation method. Meant to be extended by subclasses.
58
- def make_cookbooks
59
- create_cookbook(download_repo_path, repo_content)
60
- end
61
-
62
- def check_resource(resource, tarball, repository, position=".")
63
- resource.should_not == nil
64
- resource.repository.tag.should_not == nil
65
- resource.repository.repository_hash.should == repository.repository_hash
66
- resource.repository.checkout_hash.should_not == repository.checkout_hash
67
- resource.pos.should == position
68
- resource.metadata.should == repo_content
69
- resource.manifest.should == manifest
70
- end
71
- end
72
- end
@@ -1,128 +0,0 @@
1
- #--
2
- # Copyright: Copyright (c) 2010-2011 RightScale, Inc.
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # 'Software'), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'cookbook_helper'))
24
-
25
- describe RightScraper::Resources::Cookbook do
26
- include RightScraper::SpecHelpers::DevelopmentModeEnvironment
27
-
28
- include RightScraper::CookbookHelper
29
-
30
- shared_examples_for 'a download repository' do
31
- it_should_behave_like 'a generic repository'
32
-
33
- it 'should have no tag' do
34
- parse_url(@repository)[:tag].should be_nil
35
- end
36
- it 'should have no position' do
37
- parse_url(@repository)[:position].should be_nil
38
- end
39
- it 'should have no credentials' do
40
- parse_url(@repository)[:username].should be_nil
41
- parse_url(@repository)[:password].should be_nil
42
- end
43
- end
44
-
45
- context 'with a download repository' do
46
- before(:each) do
47
- @repository = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
48
- :repo_type => :download,
49
- :url => "http://a.site/foo/bar/baz",
50
- :first_credential => "user",
51
- :second_credential => "password")
52
- end
53
-
54
- it_should_behave_like 'a download repository'
55
-
56
- it 'should have a cookbook hash' do
57
- example_cookbook(@repository).resource_hash.should ==
58
- Digest::MD5.hexdigest(RightScraper::Resources::Cookbook::EMPTY_MANIFEST_JSON)
59
- end
60
-
61
- it 'should have a cookbook hash invariant under credential changes' do
62
- old_hash = example_cookbook(@repository).resource_hash
63
- @repository.first_credential = "b-key"
64
- example_cookbook(@repository).resource_hash.should == old_hash
65
- end
66
-
67
- it 'should have a cookbook hash invariant under position changes' do
68
- example_cookbook(@repository, "foo").resource_hash.should ==
69
- example_cookbook(@repository, "bar").resource_hash
70
- end
71
- end
72
-
73
- context 'with a download repository with a port' do
74
- before(:each) do
75
- @repository = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
76
- :repo_type => :download,
77
- :url => "http://a.site:23/foo/bar/baz",
78
- :first_credential => "user",
79
- :second_credential => "password")
80
- end
81
-
82
- it_should_behave_like 'a download repository'
83
- end
84
-
85
- context 'with a download repository with just a user' do
86
- before(:each) do
87
- @repository = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
88
- :repo_type => :download,
89
- :url => "http://a.site/foo/bar/baz",
90
- :first_credential => "user")
91
- end
92
-
93
- it_should_behave_like 'a download repository'
94
- end
95
-
96
- context 'with a weird download repository' do
97
- before(:each) do
98
- @repository = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
99
- :repo_type => :download,
100
- :url => "urn:a.site:stuff")
101
- end
102
-
103
- it_should_behave_like 'a download repository'
104
- end
105
-
106
- context 'with a malicious download repository' do
107
- before(:each) do
108
- @repository = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
109
- :repo_type => :download,
110
- :url => "http://foo.bar.baz.quux/%20CBLAH",
111
- :first_credential => "foo:b/ar",
112
- :second_credential => "foo@bar")
113
- end
114
-
115
- it_should_behave_like 'a download repository'
116
- end
117
-
118
- context 'with a download repository that includes a query' do
119
- before(:each) do
120
- @repository = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
121
- :repo_type => :download,
122
- :url => "http://foo.bar.baz.quux/stuff?q=bar")
123
- end
124
-
125
- it_should_behave_like 'a download repository'
126
- end
127
-
128
- end