コード例 #1
0
  @Test
  public void replace_user_which_not_existing_raises_exception() {

    thrown.expect(NoResultException.class);
    thrown.expectMessage(Matchers.containsString("not found"));

    accessToken = OSIAM_CONNECTOR.retrieveAccessToken("marissa", "koala", Scope.ADMIN);
    UpdateUser patchedUser = new UpdateUser.Builder().build();
    OSIAM_CONNECTOR.updateUser(NOT_EXISTING_ID, patchedUser, accessToken);
  }
コード例 #2
0
  @Test
  public void update_password() {
    createFullUser("uasv");
    createUpdateUserWithUpdateFields();

    updateUser();

    OSIAM_CONNECTOR.retrieveAccessToken("UserName", "Password", Scope.ADMIN);
  }
コード例 #3
0
  @Test
  public void update_attributes_does_not_change_the_password() {
    createFullUser("uadctp");
    createUpdateUserWithUpdateFieldsWithoutPassword();

    updateUser();

    assertThat(
        OSIAM_CONNECTOR.retrieveAccessToken(IRRELEVANT, "geheim", Scope.ADMIN), is(notNullValue()));
  }
コード例 #4
0
  @Test
  @Ignore("Fails because of a bug in resource-server")
  public void deleting_and_add_of_same_mail_address_works_independent_of_order() {
    User user = createFullUser(IRRELEVANT);
    Email email = user.getEmails().get(0);
    UpdateUser updateUser = new UpdateUser.Builder().addEmail(email).deleteEmail(email).build();

    User updatedUser = OSIAM_CONNECTOR.updateUser(user.getId(), updateUser, accessToken);

    assertThat(updatedUser.getEmails(), is(equalTo(user.getEmails())));
  }
コード例 #5
0
 @Before
 public void setUp() {
   accessToken = OSIAM_CONNECTOR.retrieveAccessToken("marissa", "koala", Scope.ADMIN);
 }
コード例 #6
0
 private void updateUser() {
   returnUser = OSIAM_CONNECTOR.updateUser(idExistingUser, updateUser, accessToken);
   // get user again from database to be able to compare with return object
   databaseUser = OSIAM_CONNECTOR.getUser(returnUser.getId(), accessToken);
 }
コード例 #7
0
  private User createFullUser(String userName) {
    User.Builder userBuilder = new User.Builder(userName);

    Email email01 =
        new Email.Builder()
            .setValue("*****@*****.**")
            .setType(Email.Type.WORK)
            .setPrimary(true)
            .build();
    Email email02 =
        new Email.Builder().setValue("*****@*****.**").setType(Email.Type.WORK).build();
    List<Email> emails = new ArrayList<>();
    emails.add(email01);
    emails.add(email02);

    PhoneNumber phoneNumber01 =
        new PhoneNumber.Builder()
            .setValue("+497845/1157")
            .setType(PhoneNumber.Type.WORK)
            .setPrimary(true)
            .build();
    PhoneNumber phoneNumber02 =
        new PhoneNumber.Builder().setValue("0245817964").setType(PhoneNumber.Type.WORK).build();
    List<PhoneNumber> phoneNumbers = new ArrayList<>();
    phoneNumbers.add(phoneNumber01);
    phoneNumbers.add(phoneNumber02);

    Address simpleAddress01 =
        new Address.Builder()
            .setCountry("de")
            .setFormatted("formated address 01")
            .setLocality("Berlin")
            .setPostalCode("111111")
            .build();
    Address simpleAddress02 =
        new Address.Builder()
            .setCountry("en")
            .setFormatted("address formated 02")
            .setLocality("New York")
            .setPostalCode("123456")
            .build();
    List<Address> addresses = new ArrayList<>();
    addresses.add(simpleAddress01);
    addresses.add(simpleAddress02);

    Entitlement entitlement01 = new Entitlement.Builder().setValue("right1").build();
    Entitlement entitlement02 = new Entitlement.Builder().setValue("right2").build();
    List<Entitlement> entitlements = new ArrayList<>();
    entitlements.add(entitlement01);
    entitlements.add(entitlement02);

    Im ims01 = new Im.Builder().setValue("ims01").setType(Im.Type.SKYPE).build();
    Im ims02 = new Im.Builder().setValue("ims02").build();
    List<Im> ims = new ArrayList<>();
    ims.add(ims01);
    ims.add(ims02);

    URI uri1 = null;
    URI uri2 = null;
    try {
      uri1 = new URI("photo01.jpg");
      uri2 = new URI("photo02.jpg");
    } catch (Exception e) {
    }

    Photo photo01 = new Photo.Builder().setValue(uri1).setType(Photo.Type.THUMBNAIL).build();

    Photo photo02 = new Photo.Builder().setValue(uri2).build();
    List<Photo> photos = new ArrayList<>();
    photos.add(photo01);
    photos.add(photo02);

    Role role01 = new Role.Builder().setValue("role01").build();
    Role role02 = new Role.Builder().setValue("role02").build();
    List<Role> roles = new ArrayList<>();
    roles.add(role01);
    roles.add(role02);

    X509Certificate certificate01 = new X509Certificate.Builder().setValue("certificate01").build();
    X509Certificate certificate02 = new X509Certificate.Builder().setValue("certificate02").build();
    List<X509Certificate> certificates = new ArrayList<>();
    certificates.add(certificate01);
    certificates.add(certificate02);

    Name name =
        new Name.Builder()
            .setFamilyName("familiyName")
            .setFormatted("formatted Name")
            .setGivenName("givenName")
            .build();

    userBuilder
        .setNickName("irgendwas")
        .addEmails(emails)
        .addPhoneNumbers(phoneNumbers)
        .setActive(false)
        .setDisplayName("irgendwas")
        .setLocale("de")
        .setPassword("geheim")
        .setPreferredLanguage("de")
        .setProfileUrl("irgendwas")
        .setTimezone("irgendwas")
        .setTitle("irgendwas")
        .setUserType("irgendwas")
        .addAddresses(addresses)
        .addIms(ims)
        .addPhotos(photos)
        .addRoles(roles)
        .setName(name)
        .addX509Certificates(certificates)
        .addEntitlements(entitlements)
        .setExternalId("irgendwas");
    User newUser = userBuilder.build();

    testUser = OSIAM_CONNECTOR.createUser(newUser, accessToken);
    idExistingUser = testUser.getId();

    return testUser;
  }