Skip to content

Commit d7273e6

Browse files
authored
Move ConsentsTest.java to the new testsuite (#40323)
* Moving files to the new test suite Signed-off-by: Lukas Hanusovsky <[email protected]> * Move ConsentsTest.java, UserRoleTest.java to the new testsuite Part of: #34494 Signed-off-by: Lukas Hanusovsky <[email protected]> --------- Signed-off-by: Lukas Hanusovsky <[email protected]>
1 parent 7fd3380 commit d7273e6

File tree

10 files changed

+541
-694
lines changed

10 files changed

+541
-694
lines changed

test-framework/core/src/main/java/org/keycloak/testframework/realm/ClientConfigBuilder.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import java.util.Arrays;
77
import java.util.HashMap;
8-
import java.util.LinkedList;
98
import java.util.List;
109

1110
public class ClientConfigBuilder {
@@ -127,19 +126,22 @@ public ClientConfigBuilder attribute(String key, String value) {
127126
}
128127

129128
public ClientConfigBuilder defaultClientScopes(String... defaultClientScopes) {
130-
if (rep.getDefaultClientScopes() == null) {
131-
rep.setDefaultClientScopes(new LinkedList<>());
132-
}
133-
134-
rep.getDefaultClientScopes().addAll(List.of(defaultClientScopes));
129+
rep.setDefaultClientScopes(Collections.combine(rep.getDefaultClientScopes(), defaultClientScopes));
135130
return this;
136131
}
137132

138133
public ClientConfigBuilder protocolMappers(List<ProtocolMapperRepresentation> mappers) {
139-
if (rep.getProtocolMappers() == null) {
140-
rep.setProtocolMappers(new LinkedList<>());
141-
}
142-
rep.getProtocolMappers().addAll(mappers);
134+
rep.setProtocolMappers(Collections.combine(rep.getProtocolMappers(), mappers));
135+
return this;
136+
}
137+
138+
public ClientConfigBuilder consentRequired(boolean enabled) {
139+
rep.setConsentRequired(enabled);
140+
return this;
141+
}
142+
143+
public ClientConfigBuilder webOrigins(String... webOrigins) {
144+
rep.setWebOrigins(Collections.combine(rep.getWebOrigins(), webOrigins));
143145
return this;
144146
}
145147

test-framework/core/src/main/java/org/keycloak/testframework/realm/RealmConfigBuilder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.keycloak.representations.idm.ClientRepresentation;
44
import org.keycloak.representations.idm.GroupRepresentation;
5+
import org.keycloak.representations.idm.IdentityProviderRepresentation;
56
import org.keycloak.representations.idm.RealmRepresentation;
67
import org.keycloak.representations.idm.RolesRepresentation;
78
import org.keycloak.representations.idm.UserRepresentation;
@@ -220,6 +221,11 @@ public RealmConfigBuilder sslRequired(String sslRequired) {
220221
return this;
221222
}
222223

224+
public RealmConfigBuilder identityProvider(IdentityProviderRepresentation identityProvider) {
225+
rep.addIdentityProvider(identityProvider);
226+
return this;
227+
}
228+
223229
/**
224230
* Best practice is to use other convenience methods when configuring a realm, but while the framework is under
225231
* active development there may not be a way to perform all updates required. In these cases this method allows
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2016 Red Hat, Inc. and/or its affiliates
3+
* and other contributors as indicated by the @author tags.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.keycloak.testframework.ui.page;
19+
20+
import org.openqa.selenium.WebDriver;
21+
import org.openqa.selenium.WebElement;
22+
import org.openqa.selenium.support.FindBy;
23+
24+
/**
25+
* @author <a href="mailto:[email protected]">Marko Strukelj</a>
26+
*/
27+
public class ConsentPage extends AbstractPage {
28+
29+
@FindBy(id = "kc-login")
30+
private WebElement submitButton;
31+
32+
@FindBy(id = "kc-cancel")
33+
private WebElement cancelButton;
34+
35+
public ConsentPage(WebDriver driver) { super(driver); }
36+
37+
public void confirm() {
38+
submitButton.click();
39+
}
40+
41+
public void cancel() {
42+
cancelButton.click();
43+
}
44+
45+
@Override
46+
public String getExpectedPageId() {
47+
return "login-login-oauth-grant";
48+
}
49+
}

test-framework/ui/src/main/java/org/keycloak/testframework/ui/page/LoginPage.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.keycloak.testframework.ui.page;
22

3+
import org.openqa.selenium.By;
34
import org.openqa.selenium.WebDriver;
45
import org.openqa.selenium.WebElement;
56
import org.openqa.selenium.support.FindBy;
@@ -28,6 +29,16 @@ public void submit() {
2829
submitButton.click();
2930
}
3031

32+
public void clickSocial(String alias) {
33+
WebElement socialButton = findSocialButton(alias);
34+
socialButton.click();
35+
}
36+
37+
public WebElement findSocialButton(String alias) {
38+
String id = "social-" + alias;
39+
return driver.findElement(By.id(id));
40+
}
41+
3142
@Override
3243
public String getExpectedPageId() {
3344
return "login-login";

0 commit comments

Comments
 (0)