/** Tests creating an account from a bundle. */
 public void testCreateAccountFromBundle() {
   final Bundle testBundle = createTestAccountBundle();
   final UserAccount account = new UserAccount(testBundle);
   assertEquals("Auth token should match", TEST_AUTH_TOKEN, account.getAuthToken());
   assertEquals("Refresh token should match", TEST_REFRESH_TOKEN, account.getRefreshToken());
   assertEquals("Login server URL should match", TEST_LOGIN_URL, account.getLoginServer());
   assertEquals("Identity URL should match", TEST_IDENTITY_URL, account.getIdUrl());
   assertEquals("Instance URL should match", TEST_INSTANCE_URL, account.getInstanceServer());
   assertEquals("Org ID should match", TEST_ORG_ID, account.getOrgId());
   assertEquals("User ID should match", TEST_USER_ID, account.getUserId());
   assertEquals("User name should match", TEST_USERNAME, account.getUsername());
   assertEquals("Client ID should match", TEST_CLIENT_ID, account.getClientId());
   assertEquals("Account name should match", TEST_ACCOUNT_NAME, account.getAccountName());
   assertEquals("Community ID should match", TEST_COMMUNITY_ID, account.getCommunityId());
   assertEquals("Community URL should match", TEST_COMMUNITY_URL, account.getCommunityUrl());
   assertEquals("First name should match", TEST_FIRST_NAME, account.getFirstName());
   assertEquals("Last name should match", TEST_LAST_NAME, account.getLastName());
   assertEquals("Display name should match", TEST_DISPLAY_NAME, account.getDisplayName());
   assertEquals("Email should match", TEST_EMAIL, account.getEmail());
   assertEquals("Photo URL should match", TEST_PHOTO_URL, account.getPhotoUrl());
   assertEquals("Thumbnail URL should match", TEST_THUMBNAIL_URL, account.getThumbnailUrl());
   assertEquals(
       "Additional OAuth values should match",
       createAdditionalOauthValues(),
       account.getAdditionalOauthValues());
 }
 /** Tests creating an account from JSON */
 public void testCreateAccountFromJSON() throws JSONException {
   JSONObject testJSON = createTestAccountJSON();
   UserAccount account = new UserAccount(testJSON);
   assertEquals("Auth token should match", TEST_AUTH_TOKEN, account.getAuthToken());
   assertEquals("Refresh token should match", TEST_REFRESH_TOKEN, account.getRefreshToken());
   assertEquals("Login server URL should match", TEST_LOGIN_URL, account.getLoginServer());
   assertEquals("Identity URL should match", TEST_IDENTITY_URL, account.getIdUrl());
   assertEquals("Instance URL should match", TEST_INSTANCE_URL, account.getInstanceServer());
   assertEquals("Org ID should match", TEST_ORG_ID, account.getOrgId());
   assertEquals("User ID should match", TEST_USER_ID, account.getUserId());
   assertEquals("User name should match", TEST_USERNAME, account.getUsername());
   assertEquals("Client ID should match", TEST_CLIENT_ID, account.getClientId());
   assertEquals("Community ID should match", TEST_COMMUNITY_ID, account.getCommunityId());
   assertEquals("Community URL should match", TEST_COMMUNITY_URL, account.getCommunityUrl());
   assertEquals("First name should match", TEST_FIRST_NAME, account.getFirstName());
   assertEquals("Last name should match", TEST_LAST_NAME, account.getLastName());
   assertEquals("Display name should match", TEST_DISPLAY_NAME, account.getDisplayName());
   assertEquals("Email should match", TEST_EMAIL, account.getEmail());
   assertEquals("Photo URL should match", TEST_PHOTO_URL, account.getPhotoUrl());
   assertEquals("Thumbnail URL should match", TEST_THUMBNAIL_URL, account.getThumbnailUrl());
   assertEquals(
       "Additional OAuth values should match",
       createAdditionalOauthValues(),
       account.getAdditionalOauthValues());
   assertEquals(
       "Account name should match",
       String.format(
           "%s (%s) (%s)",
           TEST_USERNAME,
           TEST_INSTANCE_URL,
           SalesforceSDKManager.getInstance().getApplicationName()),
       account.getAccountName());
 }
Exemplo n.º 3
0
  public ActionForward executeInContext(
      UserContext uc,
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response) {
    int uid = Integer.parseInt(request.getParameter(Constants.USER_ID_FULL));
    int custID = Integer.parseInt(request.getParameter(Constants.CUSTOMER_ID));
    IUserManager um = ManagementContainer.getInstance().getUserManager();

    UserAccount user = um.getUserAccount(custID, uid);

    if (user == null) {
      return mapping.findForward(FAILURE);
    }

    try {
      um.deleteEpaUser(user.getPrimaryEmail());
    } catch (Exception ex) {
      reportSingleError(
          request, ActionMessages.GLOBAL_MESSAGE, "error.epa.user.delete.error", ex.getMessage());
      return mapping.findForward(FAILURE);
    }

    IAuditManager auditManager = ManagementContainer.getInstance().getAuditManager();
    auditManager.saveAudit(
        IAuditManager.AuditCategory.EPA_MGMT,
        "Removed EPA user " + user.getDisplayName() + " ( " + user.getPrimaryEmail() + " )",
        "Remove EPA User Audit",
        null,
        uc.getCurrentUser().getPrimaryEmail());
    return mapping.findForward(SUCCESS);
  }