use of org.jenkinsci.plugin.gitea.client.api.GiteaAuthUser in project gitea-plugin by jenkinsci.
the class GiteaAuthSourceTest method given__userPassCredential__when__convert__then__tokenAuth.
@Test
public void given__userPassCredential__when__convert__then__tokenAuth() throws Exception {
// we use a mock to ensure that java.lang.reflect.Proxy implementations of the credential interface work
UsernamePasswordCredentials credential = Mockito.mock(UsernamePasswordCredentials.class);
Mockito.when(credential.getUsername()).thenReturn("bob");
Mockito.when(credential.getPassword()).thenReturn(Secret.fromString("secret"));
GiteaAuth auth = AuthenticationTokens.convert(GiteaAuth.class, credential);
assertThat(auth, instanceOf(GiteaAuthUser.class));
assertThat(((GiteaAuthUser) auth).getUsername(), is("bob"));
assertThat(((GiteaAuthUser) auth).getPassword(), is("secret"));
}
Aggregations