Esempio n. 1
0
  public void testGetAccount() throws Exception {
    User u1 = testHelper.makeDummyUser();
    u1 = userService.createUser(u1);

    logInUser(u1);

    MockHttpServletRequest request = createMockRequest("GET", "/account");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);

    assertEquals(response.getStatus(), MockHttpServletResponse.SC_OK);
    assertNotNull(response.getHeader("ETag"));

    CmpUser user = createUserFromXml(readXmlResponse(response));
    assertNotNull("user null", user);
    assertNotNull("user has no username", user.getUsername());
    assertEquals("usernames don't match", user.getUsername(), u1.getUsername());
    assertNotNull("user has no first name", user.getFirstName());
    assertEquals("first names don't match", user.getFirstName(), u1.getFirstName());
    assertNotNull("user has no last name", user.getLastName());
    assertEquals("last names don't match", user.getLastName(), u1.getLastName());
    assertNotNull("user has no email", user.getEmail());
    assertEquals("emails don't match", user.getEmail(), u1.getEmail());
    assertNotNull("user has no url", user.getUrl());
    assertNotNull("user has no homedir url", user.getHomedirUrl());
  }
Esempio n. 2
0
  public void testGetOverlord() throws Exception {
    MockHttpServletRequest request = createMockRequest("GET", "/user/" + User.USERNAME_OVERLORD);
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);

    assertEquals(response.getStatus(), MockHttpServletResponse.SC_OK);
    assertNotNull(response.getHeader("ETag"));

    CmpUser overlord = createUserFromXml(readXmlResponse(response));
    assertNotNull("overlord null", overlord);
    assertNotNull("overlord has no username", overlord.getUsername());
    assertEquals("usernames don't match", overlord.getUsername(), User.USERNAME_OVERLORD);
    assertNotNull("overlord has no first name", overlord.getFirstName());
    assertNotNull("overlord has no last name", overlord.getLastName());
    assertNotNull("overlord has no email", overlord.getEmail());
    assertNotNull("overlord has no url", overlord.getUrl());
    assertNull("overlord has a homedir url", overlord.getHomedirUrl());
  }
Esempio n. 3
0
 private CmpUser findUser(Set users, String username) {
   for (Iterator i = users.iterator(); i.hasNext(); ) {
     CmpUser u = (CmpUser) i.next();
     if (u.getUsername().equals(username)) {
       return u;
     }
   }
   return null;
 }
Esempio n. 4
0
  public void testGetUser() throws Exception {
    User u1 = testHelper.makeDummyUser();
    u1 = userService.createUser(u1);

    MockHttpServletRequest request = createMockRequest("GET", "/user/" + u1.getUsername());
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);

    assertEquals(response.getStatus(), MockHttpServletResponse.SC_OK);
    assertNotNull(response.getHeader("ETag"));

    CmpUser user = createUserFromXml(readXmlResponse(response));
    assertNotNull("user null", user);
    assertNotNull("user has no username", user.getUsername());
    assertEquals("usernames don't match", user.getUsername(), u1.getUsername());
    assertNotNull("user has no first name", user.getFirstName());
    assertEquals("first names don't match", user.getFirstName(), u1.getFirstName());
    assertNotNull("user has no last name", user.getLastName());
    assertEquals("last names don't match", user.getLastName(), u1.getLastName());
    assertNotNull("user has no email", user.getEmail());
    assertEquals("emails don't match", user.getEmail(), u1.getEmail());
    assertNotNull("user has no creation date", user.getCreationDate());
    assertEquals(
        "creation dates don't match",
        DateUtil.formatRfc3339Date(user.getCreationDate()),
        DateUtil.formatRfc3339Date(u1.getCreationDate()));
    assertNotNull("user has no modification date", user.getModifiedDate());
    assertEquals(
        "modification dates don't match",
        DateUtil.formatRfc3339Date(user.getModifiedDate()),
        DateUtil.formatRfc3339Date(u1.getModifiedDate()));
    assertNotNull("user has no administrator boolean", user.getAdmin());
    assertEquals("administrator booleans don't match", user.getAdmin(), u1.getAdmin());
    assertNotNull("user has no url", user.getUrl());
    assertNotNull("user has no homedir url", user.getHomedirUrl());
  }