Adds REGISTER event when new user login through first broker flow
Updates KcOidcBrokerEventTest, AbstractFirstBrokerLoginTest to factor in REGISTER event in first broker flow Closes #11646 Correcting Indentation of AbstractFirstBrokerLoginTest
This commit is contained in:
parent
2070420673
commit
c223291a1e
3 changed files with 63 additions and 5 deletions
|
@ -701,7 +701,8 @@ public class IdentityBrokerService implements IdentityProvider.AuthenticationCal
|
|||
federatedUser.setEmailVerified(true);
|
||||
}
|
||||
|
||||
event.event(EventType.REGISTER)
|
||||
event.clone()
|
||||
.event(EventType.REGISTER)
|
||||
.detail(Details.REGISTER_METHOD, "broker")
|
||||
.detail(Details.EMAIL, federatedUser.getEmail())
|
||||
.success();
|
||||
|
|
|
@ -1007,9 +1007,14 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
Assert.assertEquals("no-first-name", accountUpdateProfilePage.getUsername());
|
||||
|
||||
RealmRepresentation consumerRealmRep = adminClient.realm(bc.consumerRealmName()).toRepresentation();
|
||||
events.expectAccount(EventType.REGISTER).realm(consumerRealmRep).user(Matchers.any(String.class)).session((String) null)
|
||||
.detail(Details.IDENTITY_PROVIDER_USERNAME, "no-first-name")
|
||||
.detail(Details.REGISTER_METHOD, "broker")
|
||||
.assertEvent(getFirstConsumerEvent());
|
||||
|
||||
events.expectAccount(EventType.LOGIN).realm(consumerRealmRep).user(Matchers.any(String.class)).session(Matchers.any(String.class))
|
||||
.detail(Details.IDENTITY_PROVIDER_USERNAME, "no-first-name")
|
||||
.detail(Details.REGISTER_METHOD, "broker")
|
||||
.detail(Details.IDENTITY_PROVIDER, bc.getIDPAlias())
|
||||
.assertEvent(getFirstConsumerEvent());
|
||||
}
|
||||
|
||||
|
@ -1045,10 +1050,16 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
.detail(Details.PREVIOUS_EMAIL, "no-first-name@localhost.com")
|
||||
.detail(Details.UPDATED_EMAIL, "new-email@localhost.com")
|
||||
.assertEvent(getFirstConsumerEvent());
|
||||
events.expectAccount(EventType.LOGIN).realm(consumerRealmRep).user(Matchers.any(String.class)).session(Matchers.any(String.class))
|
||||
|
||||
events.expectAccount(EventType.REGISTER).realm(consumerRealmRep).user(Matchers.any(String.class)).session((String) null)
|
||||
.detail(Details.IDENTITY_PROVIDER_USERNAME, "no-first-name")
|
||||
.detail(Details.REGISTER_METHOD, "broker")
|
||||
.assertEvent(events.poll());
|
||||
|
||||
events.expectAccount(EventType.LOGIN).realm(consumerRealmRep).user(Matchers.any(String.class)).session(Matchers.any(String.class))
|
||||
.detail(Details.IDENTITY_PROVIDER_USERNAME, "no-first-name")
|
||||
.detail(Details.IDENTITY_PROVIDER, bc.getIDPAlias())
|
||||
.assertEvent(events.poll());
|
||||
}
|
||||
|
||||
protected EventRepresentation getFirstConsumerEvent() {
|
||||
|
|
|
@ -45,6 +45,52 @@ public final class KcOidcBrokerEventTest extends AbstractBrokerTest {
|
|||
return KcOidcBrokerConfiguration.INSTANCE;
|
||||
}
|
||||
|
||||
private void checkFirstLoginEvents(RealmResource providerRealm, RealmResource consumerRealm, String providerUserId, String consumerUserId) {
|
||||
events.expect(EventType.LOGIN)
|
||||
.realm(providerRealm.toRepresentation().getId())
|
||||
.user(providerUserId)
|
||||
.client(bc.getIDPClientIdInProviderRealm())
|
||||
.session(Matchers.any(String.class))
|
||||
.detail(Details.USERNAME, bc.getUserLogin())
|
||||
.assertEvent();
|
||||
|
||||
events.expect(EventType.CODE_TO_TOKEN)
|
||||
.session(Matchers.any(String.class))
|
||||
.realm(providerRealm.toRepresentation().getId())
|
||||
.user(providerUserId)
|
||||
.client(bc.getIDPClientIdInProviderRealm())
|
||||
.assertEvent();
|
||||
|
||||
events.expect(EventType.USER_INFO_REQUEST)
|
||||
.session(Matchers.any(String.class))
|
||||
.realm(providerRealm.toRepresentation().getId())
|
||||
.user(providerUserId)
|
||||
.client(bc.getIDPClientIdInProviderRealm())
|
||||
.assertEvent();
|
||||
|
||||
events.expect(EventType.REGISTER)
|
||||
.realm(consumerRealm.toRepresentation().getId())
|
||||
.client("account")
|
||||
.user(consumerUserId == null? Matchers.any(String.class) : Matchers.is(consumerUserId))
|
||||
.session((String) null)
|
||||
.detail(Details.USERNAME, bc.getUserLogin())
|
||||
.detail(Details.IDENTITY_PROVIDER_USERNAME, bc.getUserLogin())
|
||||
.detail(Details.IDENTITY_PROVIDER, bc.getIDPAlias())
|
||||
.assertEvent();
|
||||
|
||||
events.expect(EventType.LOGIN)
|
||||
.realm(consumerRealm.toRepresentation().getId())
|
||||
.client("account")
|
||||
.user(consumerUserId == null? Matchers.any(String.class) : Matchers.is(consumerUserId))
|
||||
.session(Matchers.any(String.class))
|
||||
.detail(Details.USERNAME, bc.getUserLogin())
|
||||
.detail(Details.IDENTITY_PROVIDER_USERNAME, bc.getUserLogin())
|
||||
.detail(Details.IDENTITY_PROVIDER, bc.getIDPAlias())
|
||||
.assertEvent();
|
||||
|
||||
events.clear();
|
||||
}
|
||||
|
||||
private void checkLoginEvents(RealmResource providerRealm, RealmResource consumerRealm, String providerUserId, String consumerUserId) {
|
||||
events.expect(EventType.LOGIN)
|
||||
.realm(providerRealm.toRepresentation().getId())
|
||||
|
@ -111,7 +157,7 @@ public final class KcOidcBrokerEventTest extends AbstractBrokerTest {
|
|||
|
||||
super.loginUser();
|
||||
|
||||
checkLoginEvents(providerRealm, consumerRealm, providerUser.getId(), null);
|
||||
checkFirstLoginEvents(providerRealm, consumerRealm, providerUser.getId(), null);
|
||||
}
|
||||
|
||||
private void loginUserAfterError() {
|
||||
|
@ -136,7 +182,7 @@ public final class KcOidcBrokerEventTest extends AbstractBrokerTest {
|
|||
UserRepresentation consumerUser = users.iterator().next();
|
||||
Assert.assertEquals(bc.getUserEmail(), consumerUser.getEmail());
|
||||
|
||||
checkLoginEvents(providerRealm, consumerRealm, providerUser.getId(), consumerUser.getId());
|
||||
checkFirstLoginEvents(providerRealm, consumerRealm, providerUser.getId(), consumerUser.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue