use of org.eclipse.che.api.factory.server.bitbucket.server.BitbucketPersonalAccessToken in project devspaces-images by redhat-developer.
the class HttpBitbucketServerApiClientTest method shouldBeAbleToCreatePAT.
@Test
public void shouldBeAbleToCreatePAT() throws ScmCommunicationException, ScmBadRequestException, ScmUnauthorizedException {
// given
stubFor(put(urlPathEqualTo("/rest/access-tokens/1.0/users/ksmster")).withHeader(HttpHeaders.AUTHORIZATION, equalTo(AUTHORIZATION_TOKEN)).withHeader(HttpHeaders.ACCEPT, equalTo(MediaType.APPLICATION_JSON)).withHeader(HttpHeaders.CONTENT_TYPE, equalTo(MediaType.APPLICATION_JSON)).withHeader(HttpHeaders.CONTENT_LENGTH, equalTo("63")).willReturn(ok().withBodyFile("bitbucket/rest/access-tokens/1.0/users/ksmster/newtoken.json")));
// when
BitbucketPersonalAccessToken result = bitbucketServer.createPersonalAccessTokens("ksmster", "myToKen", ImmutableSet.of("PROJECT_WRITE", "REPO_WRITE"));
// then
assertNotNull(result);
assertEquals(result.getToken(), "MTU4OTEwNTMyOTA5Ohc88HcY8k7gWOzl2mP5TtdtY5Qs");
}
use of org.eclipse.che.api.factory.server.bitbucket.server.BitbucketPersonalAccessToken in project devspaces-images by redhat-developer.
the class HttpBitbucketServerApiClientTest method shouldBeAbleToGetExistedPAT.
@Test
public void shouldBeAbleToGetExistedPAT() throws ScmCommunicationException, ScmUnauthorizedException, ScmItemNotFoundException {
// given
stubFor(get(urlPathEqualTo("/rest/access-tokens/1.0/users/ksmster/5")).withHeader(HttpHeaders.AUTHORIZATION, equalTo(AUTHORIZATION_TOKEN)).withHeader(HttpHeaders.ACCEPT, equalTo(MediaType.APPLICATION_JSON)).willReturn(ok().withBodyFile("bitbucket/rest/access-tokens/1.0/users/ksmster/newtoken.json")));
// when
BitbucketPersonalAccessToken result = bitbucketServer.getPersonalAccessToken("ksmster", 5L);
// then
assertNotNull(result);
assertEquals(result.getToken(), "MTU4OTEwNTMyOTA5Ohc88HcY8k7gWOzl2mP5TtdtY5Qs");
}
Aggregations