package org.jenkinsci.plugins.p4_client.credentials; import hudson.security.ACL; import java.io.IOException; import java.util.List; import jenkins.model.Jenkins; import org.acegisecurity.Authentication; import org.jvnet.hudson.test.HudsonTestCase; import com.cloudbees.plugins.credentials.CredentialsProvider; import com.cloudbees.plugins.credentials.CredentialsScope; import com.cloudbees.plugins.credentials.SystemCredentialsProvider; import com.cloudbees.plugins.credentials.domains.DomainRequirement; public class PerforceCredentialsTest extends HudsonTestCase { public void testAddPasswordCredentials() throws IOException { assertTrue(lookupCredentials().isEmpty()); SystemCredentialsProvider .getInstance() .getCredentials() .add(new P4PasswordImpl(CredentialsScope.SYSTEM, "id", "description", "localhost:1666", null, "user", "pass")); assertFalse(lookupCredentials().isEmpty()); assertTrue(new SystemCredentialsProvider().getCredentials().isEmpty()); SystemCredentialsProvider.getInstance().save(); assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty()); } public void testAddTicketCredentials() throws IOException { TicketModeImpl ticket = new TicketModeImpl("ticketValueSet", "12345", null); assertTrue(lookupCredentials().isEmpty()); SystemCredentialsProvider .getInstance() .getCredentials() .add(new P4TicketImpl(CredentialsScope.SYSTEM, "id", "description", "localhost:1666", null, "user", ticket)); assertFalse(lookupCredentials().isEmpty()); assertTrue(new SystemCredentialsProvider().getCredentials().isEmpty()); SystemCredentialsProvider.getInstance().save(); assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty()); } public void testAddTicketPathCredentials() throws IOException { TicketModeImpl ticket = new TicketModeImpl("ticketPathSet", null, "~/.p4ticket"); assertTrue(lookupCredentials().isEmpty()); SystemCredentialsProvider .getInstance() .getCredentials() .add(new P4TicketImpl(CredentialsScope.SYSTEM, "id", "description", "localhost:1666", null, "user", ticket)); assertFalse(lookupCredentials().isEmpty()); assertTrue(new SystemCredentialsProvider().getCredentials().isEmpty()); SystemCredentialsProvider.getInstance().save(); assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty()); } private List<P4StandardCredentials> lookupCredentials() { Class<P4StandardCredentials> type = P4StandardCredentials.class; Jenkins scope = Jenkins.getInstance(); Authentication acl = ACL.SYSTEM; DomainRequirement domain = new DomainRequirement(); return CredentialsProvider.lookupCredentials(type, scope, acl, domain); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
#4 | 8902 | Paul Allen |
Updated test cases: Pushed Workspace 'charset' to abstract Workspace class. Minor bugfixes in Workspace AutoCompletionCandidates method. |
||
#3 | 8898 | Paul Allen | Removed Deprecated 'HudsonTestCase' for Jenkins @Rule | ||
#2 | 8888 | Paul Allen |
Extended test coverage for Workspace and Credentials. - Removed ununsed methods. |
||
#1 | 8761 | Paul Allen | Basic unit tests for PerforceScm configuration and Credentials. |