From f5947cc0a33097028ee038c3ebffdf5a5423bb20 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Thu, 25 Jun 2015 21:14:49 -0700 Subject: [PATCH] Fix a small bug in URIRequirementBuilder. When a path is used in the URIRequirementBuilder, it cleared any SchemeRequirement already set. This appears to be a copy-paste error. --- .../plugins/credentials/domains/URIRequirementBuilder.java | 2 +- .../com/cloudbees/plugins/credentials/domains/DomainTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cloudbees/plugins/credentials/domains/URIRequirementBuilder.java b/src/main/java/com/cloudbees/plugins/credentials/domains/URIRequirementBuilder.java index 2e5d1a439..691c1a1d3 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/domains/URIRequirementBuilder.java +++ b/src/main/java/com/cloudbees/plugins/credentials/domains/URIRequirementBuilder.java @@ -196,7 +196,7 @@ public URIRequirementBuilder withScheme(@CheckForNull String scheme) { */ @NonNull public URIRequirementBuilder withPath(@CheckForNull String path) { - withoutScheme(); + withoutPath(); if (path != null) { requirements.add(new PathRequirement(path)); } diff --git a/src/test/java/com/cloudbees/plugins/credentials/domains/DomainTest.java b/src/test/java/com/cloudbees/plugins/credentials/domains/DomainTest.java index 1b3b5ea87..a8e87a68b 100644 --- a/src/test/java/com/cloudbees/plugins/credentials/domains/DomainTest.java +++ b/src/test/java/com/cloudbees/plugins/credentials/domains/DomainTest.java @@ -48,7 +48,7 @@ public void smokes() throws Exception { public void pathRequirements() throws Exception { Domain instance = new Domain("test federation", "the instance under test", Arrays.asList( - new SchemeSpecification("http, https, svn, git, pop3, imap, spdy"), + new SchemeSpecification("https"), new HostnameSpecification("*.jenkins-ci.org", null), new PathSpecification("/download/**/jenkins.war", null, false))); @@ -56,6 +56,7 @@ public void pathRequirements() throws Exception { assertThat(instance.test(URIRequirementBuilder.fromUri("https://updates.jenkins-ci.org/download/1.532/jenkins.war").build()), is(true)); assertThat(instance.test(URIRequirementBuilder.fromUri("https://updates.jenkins-ci.org/download/jenkins.war").build()), is(true)); assertThat(instance.test(URIRequirementBuilder.fromUri("https://updates.jenkins-ci.org/download/1/2/3/jenkins.war").build()), is(true)); + assertThat(instance.test(URIRequirementBuilder.fromUri("http://updates.jenkins-ci.org/download/1/2/3/jenkins.war").build()), is(false)); } }