Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-33944] Don't set credential ids in test
  • Loading branch information
armfergom committed Apr 5, 2016
1 parent 5655353 commit b0512a2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/test/java/core/CredentialsTest.java
Expand Up @@ -21,7 +21,6 @@ public class CredentialsTest extends AbstractJUnitTest {
private static final String GLOBAL_SCOPE = "GLOBAL";
private static final String SYSTEM_SCOPE = "SYSTEM";

private static final String CRED_ID = "ID";
private static final String CRED_USER = "user";
private static final String CRED_PWD = "password";

Expand All @@ -33,7 +32,6 @@ public void createSshKeys() {
final SshPrivateKeyCredential sc = c.add(SshPrivateKeyCredential.class);
sc.username.set(CRED_USER);
sc.selectEnterDirectly().privateKey.set(CRED_PWD);
sc.setId(CRED_ID);
c.save();

//now verify
Expand All @@ -46,7 +44,7 @@ public void createUserPwd() {
final ManagedCredentials c = new ManagedCredentials(jenkins);

c.open();
final UserPwdCredential upc = createUserPwdCredential(c.add(UserPwdCredential.class), CRED_ID, CRED_USER, CRED_PWD, null, null);
final UserPwdCredential upc = createUserPwdCredential(c.add(UserPwdCredential.class), CRED_USER, CRED_PWD, null, null);
c.save();

//now verify
Expand All @@ -69,7 +67,7 @@ private void createUpdateDeleteTest(String systemScope) {

// Create credential
c.open();
final UserPwdCredential upc = createUserPwdCredential(c.add(UserPwdCredential.class), CRED_ID, CRED_USER, CRED_PWD, "Descr", systemScope);
final UserPwdCredential upc = createUserPwdCredential(c.add(UserPwdCredential.class), CRED_USER, CRED_PWD, "Descr", systemScope);
c.save();

// verify credential was created
Expand Down Expand Up @@ -102,7 +100,7 @@ public void manageDomainCredentialsTest() {
Domain d = c.addDomain();
d.name.set(domainName);
d.description.set("domain description");
final UserPwdCredential credInDomain = createUserPwdCredential(d.addCredential(UserPwdCredential.class), CRED_ID, CRED_USER, CRED_PWD, "descr", SYSTEM_SCOPE);
final UserPwdCredential credInDomain = createUserPwdCredential(d.addCredential(UserPwdCredential.class), CRED_USER, CRED_PWD, "descr", SYSTEM_SCOPE);
c.save();

verifyValueForElement(credInDomain.username, CRED_USER);
Expand Down Expand Up @@ -136,12 +134,12 @@ public void domainScopedAndGlobalDomainCredentialsTest() {
Domain d = c.addDomain();
d.name.set(domainName);
d.description.set("domain description");
final UserPwdCredential credInDomain = createUserPwdCredential(d.addCredential(UserPwdCredential.class), CRED_ID, domainCredUser, CRED_PWD, "descr", SYSTEM_SCOPE);
final UserPwdCredential credInDomain = createUserPwdCredential(d.addCredential(UserPwdCredential.class), domainCredUser, CRED_PWD, "descr", SYSTEM_SCOPE);
c.save();

// Create global domain credential
c.open();
final UserPwdCredential globalCred = createUserPwdCredential(c.add(UserPwdCredential.class), CRED_ID, globalCredUser, CRED_PWD, "descr", SYSTEM_SCOPE);
final UserPwdCredential globalCred = createUserPwdCredential(c.add(UserPwdCredential.class), globalCredUser, CRED_PWD, "descr", SYSTEM_SCOPE);
c.save();

jenkins.visit("credentials");
Expand All @@ -164,17 +162,13 @@ private void verifyElementNotPresent(Control element) {
* Populates a UserPwdCredential with the values passed as parameter
*
* @param c The credential
* @param id (optional) The id of the credential
* @param user The username
* @param pwd The password
* @param descr (optional) The description of the credential
* @param systemScope (optional) The scope of the credential
* @return
*/
private UserPwdCredential createUserPwdCredential(final UserPwdCredential c, String id, String user, String pwd, String descr, String scope) {
if (id != null && !id.isEmpty()) {
c.setId(id);
}
private UserPwdCredential createUserPwdCredential(final UserPwdCredential c, String user, String pwd, String descr, String scope) {
if (descr != null && !descr.isEmpty()) {
c.description.set(descr);
}
Expand Down

0 comments on commit b0512a2

Please sign in to comment.