summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-16 21:56:55 -0700
committerTim Smith <tsmith@chef.io>2018-03-19 15:28:34 -0700
commitaadb71878889f615c3b014bb32afecd043a0a678 (patch)
treea33975e933041989d45913d51476e97b76412d94 /spec
parent4e6c7972620e68753946abe109895762a6301efd (diff)
downloadchef-aadb71878889f615c3b014bb32afecd043a0a678.tar.gz
Fail with a warning if users specify apt/yum/zypper repos with slashesrepo_filenames
We can't write out a filename like foo/bar.repo so we should properly warn the user if they try to give us that. There's probably other things, but this one makes particular sense for apt since people want to use the slash in PPA repo names. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/resource/apt_repository_spec.rb4
-rw-r--r--spec/unit/resource/yum_repository_spec.rb4
-rw-r--r--spec/unit/resource/zypper_repository_spec.rb4
3 files changed, 12 insertions, 0 deletions
diff --git a/spec/unit/resource/apt_repository_spec.rb b/spec/unit/resource/apt_repository_spec.rb
index fecf3be582..296bb89455 100644
--- a/spec/unit/resource/apt_repository_spec.rb
+++ b/spec/unit/resource/apt_repository_spec.rb
@@ -28,6 +28,10 @@ describe Chef::Resource::AptRepository do
expect(resource.keyserver).to eql("keyserver.ubuntu.com")
end
+ it "fails if the user provides a repo_name with a forward slash" do
+ expect { resource.repo_name "foo/bar" }.to raise_error(ArgumentError)
+ end
+
it "resolves to a Noop class when on non-linux OS" do
node.automatic[:os] = "windows"
node.automatic[:platform_family] = "windows"
diff --git a/spec/unit/resource/yum_repository_spec.rb b/spec/unit/resource/yum_repository_spec.rb
index 3ff9b85f88..353ff7ce23 100644
--- a/spec/unit/resource/yum_repository_spec.rb
+++ b/spec/unit/resource/yum_repository_spec.rb
@@ -32,6 +32,10 @@ describe Chef::Resource::YumRepository do
expect(resource.repositoryid).to eq("multiverse")
end
+ it "fails if the user provides a repositoryid with a forward slash" do
+ expect { resource.repositoryid "foo/bar" }.to raise_error(ArgumentError)
+ end
+
it "the timeout property expects numeric Strings" do
expect { resource.timeout "123" }.not_to raise_error(ArgumentError)
expect { resource.timeout "123foo" }.to raise_error(ArgumentError)
diff --git a/spec/unit/resource/zypper_repository_spec.rb b/spec/unit/resource/zypper_repository_spec.rb
index 889a1e1e9a..8f93aecd8e 100644
--- a/spec/unit/resource/zypper_repository_spec.rb
+++ b/spec/unit/resource/zypper_repository_spec.rb
@@ -32,6 +32,10 @@ describe Chef::Resource::ZypperRepository do
expect(resource.repo_name).to eql("repo-source")
end
+ it "fails if the user provides a repo_name with a forward slash" do
+ expect { resource.repo_name "foo/bar" }.to raise_error(ArgumentError)
+ end
+
it "has a default action of create" do
expect(resource.action).to eql([:create])
end