use of org.keycloak.testsuite.broker.SocialLoginTest in project keycloak by keycloak.
the class ReAuthenticationTest method loadTestRealm.
private RealmRepresentation loadTestRealm() {
RealmRepresentation res = loadJson(getClass().getResourceAsStream("/testrealm.json"), RealmRepresentation.class);
res.setBrowserFlow("browser");
res.setRememberMe(true);
// Add some sample dummy GitHub, Gitlab & Google social providers to the testing realm. Those are dummy providers for test if they are visible (clickable)
// on the login pages
List<IdentityProviderRepresentation> idps = new ArrayList<>();
for (SocialLoginTest.Provider provider : Arrays.asList(GITHUB, GOOGLE)) {
SocialLoginTest socialLoginTest = new SocialLoginTest();
idps.add(socialLoginTest.buildIdp(provider));
}
res.setIdentityProviders(idps);
return res;
}
use of org.keycloak.testsuite.broker.SocialLoginTest in project keycloak by keycloak.
the class BrowserFlowTest method testSocialProvidersPresentOnLoginUsernameOnlyPageIfConfigured.
@Test
@AuthServerContainerExclude(REMOTE)
public void testSocialProvidersPresentOnLoginUsernameOnlyPageIfConfigured() {
String testRealm = "test";
// Test setup - Configure the testing Keycloak instance with UsernameForm & PasswordForm (both REQUIRED) and OTPFormAuthenticator (ALTERNATIVE)
configureBrowserFlowWithRequiredPasswordFormAndAlternativeOTP("browser - copy 1");
try {
SocialLoginTest socialLoginTest = new SocialLoginTest();
// matters is if they are visible (clickable) on the LoginUsernameOnlyPage once the page is loaded
for (SocialLoginTest.Provider provider : Arrays.asList(GITHUB, GITLAB, GOOGLE)) {
adminClient.realm(testRealm).identityProviders().create(socialLoginTest.buildIdp(provider));
loginUsernameOnlyPage.open();
loginUsernameOnlyPage.assertCurrent();
// For each of the testing social providers, check the particular social provider button is present on the UsernameForm
// Test succeeded if NoSuchElementException is thrown for none of them
loginUsernameOnlyPage.findSocialButton(provider.id());
}
// Test cleanup - Return back to the initial state
} finally {
// Drop the testing social providers previously created within the test
for (IdentityProviderRepresentation providerRepresentation : adminClient.realm(testRealm).identityProviders().findAll()) {
adminClient.realm(testRealm).identityProviders().get(providerRepresentation.getInternalId()).remove();
}
revertFlows("browser - copy 1");
}
}
Aggregations