diff --git a/src/main/resources/com/cloudbees/plugins/credentials/impl/BaseStandardCredentials/id-and-description.jelly b/src/main/resources/com/cloudbees/plugins/credentials/impl/BaseStandardCredentials/id-and-description.jelly index a3a35c7be..ca3ae2d1c 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/impl/BaseStandardCredentials/id-and-description.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/impl/BaseStandardCredentials/id-and-description.jelly @@ -31,7 +31,6 @@ diff --git a/src/test/java/com/cloudbees/plugins/credentials/impl/BaseStandardCredentialsTest.java b/src/test/java/com/cloudbees/plugins/credentials/impl/BaseStandardCredentialsTest.java index d6c8d5eee..dd8c30ba4 100644 --- a/src/test/java/com/cloudbees/plugins/credentials/impl/BaseStandardCredentialsTest.java +++ b/src/test/java/com/cloudbees/plugins/credentials/impl/BaseStandardCredentialsTest.java @@ -29,6 +29,7 @@ import com.cloudbees.plugins.credentials.CredentialsStore; import com.cloudbees.plugins.credentials.common.IdCredentials; import com.cloudbees.plugins.credentials.domains.Domain; +import com.gargoylesoftware.htmlunit.html.HtmlPage; import hudson.model.ModelObject; import hudson.model.User; import hudson.security.ACL; @@ -41,11 +42,15 @@ import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.MockFolder; +import org.xml.sax.SAXException; import static hudson.util.FormValidation.Kind.ERROR; import static hudson.util.FormValidation.Kind.OK; import static hudson.util.FormValidation.Kind.WARNING; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; public class BaseStandardCredentialsTest { @@ -138,6 +143,17 @@ public void run() { // TODO could test the case that alice has Item.READ but not CredentialsProvider.VIEW on a folder, and mocks a web request passing that folder as context } + + @Test + public void noIDValidationMessageOnCredentialsUpdate() throws IOException, SAXException { + // create credentials with ID test + CredentialsStore store = lookupStore(r.jenkins); + addCreds(store, CredentialsScope.GLOBAL, "test"); + // check there is no validation message about a duplicated ID when updating + JenkinsRule.WebClient webClient = r.createWebClient(); + HtmlPage htmlPage = webClient.goTo("credentials/store/system/domain/_/credential/test/update"); + assertThat(htmlPage.asText(), not(containsString("This ID is already in use"))); + } private static CredentialsStore lookupStore(ModelObject object) { Iterator stores = CredentialsProvider.lookupStores(object).iterator();