-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bumped Keycloak version to 13.0.1 (#3)
* simplified tests * simplified tests * Cucumber tests! * tests polish * bumped Keycloak version to 13.0.1 * renamed job
- Loading branch information
1 parent
a7dae7e
commit a2d3bbe
Showing
13 changed files
with
157 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/test/java/io.github.kilmajster.keycloak/CucumberConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.kilmajster.keycloak; | ||
|
||
import io.cucumber.junit.Cucumber; | ||
import io.cucumber.junit.CucumberOptions; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(Cucumber.class) | ||
@CucumberOptions(features = "src/test/resources/cucumber") | ||
public class CucumberConfig { | ||
} |
93 changes: 93 additions & 0 deletions
93
src/test/java/io.github.kilmajster.keycloak/KeycloakSteps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package io.github.kilmajster.keycloak; | ||
|
||
import com.codeborne.selenide.SelenideElement; | ||
import dasniko.testcontainers.keycloak.KeycloakContainer; | ||
import io.cucumber.java.en.And; | ||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
import org.junit.Before; | ||
import org.openqa.selenium.By; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.testcontainers.containers.output.Slf4jLogConsumer; | ||
|
||
import static com.codeborne.selenide.Condition.text; | ||
import static com.codeborne.selenide.Selenide.$; | ||
import static com.codeborne.selenide.Selenide.open; | ||
import static io.github.kilmajster.keycloak.TestConstants.*; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public final class KeycloakSteps { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(KeycloakSteps.class); | ||
|
||
private final KeycloakContainer keycloak = new KeycloakContainer(KEYCLOAK_DEV_DOCKER_IMAGE) | ||
.withRealmImportFile("dev-realm.json") | ||
.withLogConsumer(new Slf4jLogConsumer(log)); | ||
|
||
@Given("keycloak is running with default setup") | ||
public void keycloak_is_running_with_default_setup() { | ||
if (!keycloak.isRunning()) { | ||
log.info("Starting keycloak container..."); | ||
keycloak.start(); | ||
} | ||
} | ||
|
||
@Given("keycloak is running with LOGIN_FORM_ATTRIBUTE_LABEL = {string}") | ||
public void keycloak_is_running_with_login_form_attribute_label_env(final String envLoginFormAttributeLabel) { | ||
keycloak.addEnv("LOGIN_FORM_ATTRIBUTE_LABEL", envLoginFormAttributeLabel); | ||
if (!keycloak.isRunning()) { | ||
log.info("Starting keycloak container with LOGIN_FORM_ATTRIBUTE_LABEL = " + envLoginFormAttributeLabel); | ||
keycloak.start(); | ||
} | ||
} | ||
|
||
@When("user goes to the account console page") | ||
public void go_to_keycloak_account_page() { | ||
final String keycloakUrl = TestConstants.KEYCLOAK_LOCAL_URL_PREFIX + keycloak.getFirstMappedPort(); | ||
open(keycloakUrl + "/auth/realms/dev-realm/account"); | ||
} | ||
|
||
@Then("user should be not logged in") | ||
public void user_should_be_not_logged_in() { | ||
final String loggedInUser = $(By.id("landingLoggedInUser")).val(); | ||
assertThat(loggedInUser).isNullOrEmpty(); | ||
} | ||
|
||
@When("user clicks a sign in button") | ||
public static void click_sign_in_button() { | ||
log.info("click_sign_in_button()"); | ||
|
||
$(By.id("landingSignInButton")).click(); | ||
} | ||
|
||
@Then("login form with attribute input labeled as {string} should be shown") | ||
public static void verify_login_form_is_displayed_with_user_attribute_label(final String label) { | ||
log.info("verify_login_form_is_displayed_with_user_attribute_label( label = " + label + " )"); | ||
|
||
assertThat($(By.id("kc-form-login")).isDisplayed()).isTrue(); | ||
userAttributeFormLabel().shouldHave(text(label)); | ||
} | ||
|
||
@When("user log into account console with a valid credentials and user attribute equal {string}") | ||
public static void log_into_account_console(final String attribute) { | ||
log.info("log_into_account_console()"); | ||
|
||
$(By.id("username")).val(TEST_USERNAME); | ||
$(By.id("password")).val(TEST_PASSWORD); | ||
$(By.id("login_form_user_attribute")).val(attribute); | ||
$(By.id("kc-login")).click(); | ||
} | ||
|
||
@Then("user should be logged into account console") | ||
public static void verify_that_user_is_logged_in() { | ||
log.info("verify_that_user_is_logged_in()"); | ||
|
||
$(By.id("landingLoggedInUser")).shouldHave(text("test")); | ||
} | ||
|
||
private static SelenideElement userAttributeFormLabel() { | ||
return $(By.xpath("//input[@id='login_form_user_attribute']/preceding-sibling::label")); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/java/io.github.kilmajster.keycloak/TestConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.github.kilmajster.keycloak; | ||
|
||
public interface TestConstants { | ||
String KEYCLOAK_DEV_DOCKER_IMAGE = "kilmajster/keycloak-with-authenticator:test"; | ||
String KEYCLOAK_LOCAL_URL_PREFIX = "http://localhost:"; | ||
|
||
String TEST_USERNAME = "test"; | ||
String TEST_PASSWORD = "test"; | ||
} |
32 changes: 0 additions & 32 deletions
32
src/test/java/io.github.kilmajster.keycloak/UsernamePasswordAttributeFormAT.java
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
src/test/java/io.github.kilmajster.keycloak/UsernamePasswordAttributeFormEnvVarConfigAT.java
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
src/test/java/io.github.kilmajster.keycloak/base/BaseKeycloakInDockerAT.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.