Search in sources :

Example 6 with Attribute

use of io.gravitee.am.model.scim.Attribute in project gravitee-access-management by gravitee-io.

the class UserFactorUpdaterTest method shouldNotUpdateEmail_TooMuchDiff.

@Test
public void shouldNotUpdateEmail_TooMuchDiff() {
    User existingUser = new User();
    existingUser.setEmail("email@domain.org");
    Attribute email1 = new Attribute();
    email1.setValue(existingUser.getEmail());
    Attribute email2 = new Attribute();
    email2.setValue("email2@domain.org");
    Attribute email3 = new Attribute();
    email3.setValue("email3@domain.org");
    existingUser.setEmails(Arrays.asList(email1, email2, email3));
    EnrolledFactor factor = new EnrolledFactor();
    factor.setChannel(new EnrolledFactorChannel(EnrolledFactorChannel.Type.EMAIL, email3.getValue()));
    User updatedUser = new User();
    updatedUser.setEmail(null);
    Attribute uemail1 = new Attribute();
    // value is the same
    uemail1.setValue(email1.getValue());
    Attribute uemail2 = new Attribute();
    uemail2.setValue("uemail2@domain.org");
    Attribute uemail3 = new Attribute();
    uemail3.setValue("uemail3@domain.org");
    updatedUser.setEmails(Arrays.asList(uemail1, uemail2, uemail3));
    UserFactorUpdater.updateFactors(singletonList(factor), existingUser, updatedUser);
    assertEquals("Email should not be updated", email3.getValue(), factor.getChannel().getTarget());
}
Also used : EnrolledFactorChannel(io.gravitee.am.model.factor.EnrolledFactorChannel) User(io.gravitee.am.model.User) Attribute(io.gravitee.am.model.scim.Attribute) EnrolledFactor(io.gravitee.am.model.factor.EnrolledFactor) Test(org.junit.Test)

Aggregations

User (io.gravitee.am.model.User)6 EnrolledFactor (io.gravitee.am.model.factor.EnrolledFactor)6 EnrolledFactorChannel (io.gravitee.am.model.factor.EnrolledFactorChannel)6 Attribute (io.gravitee.am.model.scim.Attribute)6 Test (org.junit.Test)3 EnrolledFactorSecurity (io.gravitee.am.model.factor.EnrolledFactorSecurity)2 Address (io.gravitee.am.model.scim.Address)2 Certificate (io.gravitee.am.model.scim.Certificate)2 EventType (io.gravitee.am.common.audit.EventType)1 Action (io.gravitee.am.common.event.Action)1 Type (io.gravitee.am.common.event.Type)1 ReferenceType (io.gravitee.am.model.ReferenceType)1 AnalyticsQuery (io.gravitee.am.model.analytics.AnalyticsQuery)1 Page (io.gravitee.am.model.common.Page)1 Event (io.gravitee.am.model.common.event.Event)1 Payload (io.gravitee.am.model.common.event.Payload)1 FactorStatus (io.gravitee.am.model.factor.FactorStatus)1 UserRepository (io.gravitee.am.repository.management.api.UserRepository)1 AuditService (io.gravitee.am.service.AuditService)1 UserService (io.gravitee.am.service.UserService)1