Search in sources :

Example 1 with HttpBitbucketServerApiClient

use of org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient in project che-server by eclipse-che.

the class HttpBitbucketServerApiClientTest method start.

@BeforeMethod
void start() {
    wireMockServer = new WireMockServer(wireMockConfig().notifier(new Slf4jNotifier(false)).dynamicPort());
    wireMockServer.start();
    WireMock.configureFor("localhost", wireMockServer.port());
    wireMock = new WireMock("localhost", wireMockServer.port());
    bitbucketServer = new HttpBitbucketServerApiClient(wireMockServer.url("/"), new BitbucketServerOAuthAuthenticator("", "", "", "") {

        @Override
        public String computeAuthorizationHeader(String userId, String requestMethod, String requestUrl) throws OAuthAuthenticationException {
            return AUTHORIZATION_TOKEN;
        }
    });
}
Also used : BitbucketServerOAuthAuthenticator(org.eclipse.che.security.oauth1.BitbucketServerOAuthAuthenticator) HttpBitbucketServerApiClient(org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) Slf4jNotifier(com.github.tomakehurst.wiremock.common.Slf4jNotifier) WireMock(com.github.tomakehurst.wiremock.client.WireMock) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with HttpBitbucketServerApiClient

use of org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient in project che-server by eclipse-che.

the class HttpBitbucketServerApiClientTest method shouldThrowScmCommunicationExceptionInNoOauthAuthenticator.

@Test(expectedExceptions = ScmCommunicationException.class, expectedExceptionsMessageRegExp = "The fallback noop authenticator cannot be used for authentication. Make sure OAuth is properly configured.")
public void shouldThrowScmCommunicationExceptionInNoOauthAuthenticator() throws ScmCommunicationException, ScmUnauthorizedException, ScmItemNotFoundException {
    HttpBitbucketServerApiClient localServer = new HttpBitbucketServerApiClient(wireMockServer.url("/"), new NoopOAuthAuthenticator());
    // when
    localServer.getPersonalAccessToken("ksmster", 5L);
}
Also used : NoopOAuthAuthenticator(org.eclipse.che.security.oauth1.NoopOAuthAuthenticator) HttpBitbucketServerApiClient(org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient) Test(org.testng.annotations.Test)

Example 3 with HttpBitbucketServerApiClient

use of org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient in project devspaces-images by redhat-developer.

the class HttpBitbucketServerApiClientTest method start.

@BeforeMethod
void start() {
    wireMockServer = new WireMockServer(wireMockConfig().notifier(new Slf4jNotifier(false)).dynamicPort());
    wireMockServer.start();
    WireMock.configureFor("localhost", wireMockServer.port());
    wireMock = new WireMock("localhost", wireMockServer.port());
    bitbucketServer = new HttpBitbucketServerApiClient(wireMockServer.url("/"), new BitbucketServerOAuthAuthenticator("", "", "", "") {

        @Override
        public String computeAuthorizationHeader(String userId, String requestMethod, String requestUrl) throws OAuthAuthenticationException {
            return AUTHORIZATION_TOKEN;
        }
    });
}
Also used : BitbucketServerOAuthAuthenticator(org.eclipse.che.security.oauth1.BitbucketServerOAuthAuthenticator) HttpBitbucketServerApiClient(org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) Slf4jNotifier(com.github.tomakehurst.wiremock.common.Slf4jNotifier) WireMock(com.github.tomakehurst.wiremock.client.WireMock) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with HttpBitbucketServerApiClient

use of org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient in project devspaces-images by redhat-developer.

the class HttpBitbucketServerApiClientTest method shouldThrowScmCommunicationExceptionInNoOauthAuthenticator.

@Test(expectedExceptions = ScmCommunicationException.class, expectedExceptionsMessageRegExp = "The fallback noop authenticator cannot be used for authentication. Make sure OAuth is properly configured.")
public void shouldThrowScmCommunicationExceptionInNoOauthAuthenticator() throws ScmCommunicationException, ScmUnauthorizedException, ScmItemNotFoundException {
    HttpBitbucketServerApiClient localServer = new HttpBitbucketServerApiClient(wireMockServer.url("/"), new NoopOAuthAuthenticator());
    // when
    localServer.getPersonalAccessToken("ksmster", 5L);
}
Also used : NoopOAuthAuthenticator(org.eclipse.che.security.oauth1.NoopOAuthAuthenticator) HttpBitbucketServerApiClient(org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient) Test(org.testng.annotations.Test)

Aggregations

HttpBitbucketServerApiClient (org.eclipse.che.api.factory.server.bitbucket.server.HttpBitbucketServerApiClient)4 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)2 WireMock (com.github.tomakehurst.wiremock.client.WireMock)2 Slf4jNotifier (com.github.tomakehurst.wiremock.common.Slf4jNotifier)2 BitbucketServerOAuthAuthenticator (org.eclipse.che.security.oauth1.BitbucketServerOAuthAuthenticator)2 NoopOAuthAuthenticator (org.eclipse.che.security.oauth1.NoopOAuthAuthenticator)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Test (org.testng.annotations.Test)2