@Test(
      expectedExceptions = IllegalArgumentException.class,
      expectedExceptionsMessageRegExp = "Can't validate subscription. End date attribute is absent")
  public void testCheckSubscriptionErrorIfEndDateIsAbsent() throws Exception {
    when(transport.doGet(endsWith("account"), eq(TOKEN)))
        .thenReturn("[{roles:[\"account/owner\"],accountReference:{id:accountId}}]");
    when(transport.doGet(endsWith("subscription/find/account?id=accountId"), eq(TOKEN)))
        .thenReturn("[{serviceId:OnPremises,id:subscriptionId,startDate:\"10/12/2012\"}]");

    saasAccountServiceProxy.hasValidSubscription(SUBSCRIPTION, TOKEN, ACCOUNT_ID);
  }
예제 #2
0
  /**
   * Logins to Codenvy SaaS.
   *
   * @throws org.eclipse.che.api.auth.AuthenticationException if login fails
   * @throws IOException if unexpected error occurred
   */
  public Token login(Credentials credentials) throws AuthenticationException, IOException {
    String requestUrl = combinePaths(saasApiEndpoint, "/auth/login");

    String response;
    try {
      response = transport.doPost(requestUrl, credentials);
    } catch (HttpException e) {
      throw new AuthenticationException();
    }

    return createDtoFromJson(response, Token.class);
  }
예제 #3
0
 /**
  * Logout from Codenvy SaaS.
  *
  * @throws IOException if unexpected error occurred
  */
 public void logout(String authToken) throws IOException {
   String requestUrl = combinePaths(saasApiEndpoint, "/auth/logout?token=" + authToken);
   transport.doPost(requestUrl, null);
 }