generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tidying gradle test tasks * PO-220 integrate get token with defined user * checkstyle * junit report issue * fixing spelling mistake in BearerTokenStepDef
- Loading branch information
1 parent
0d57371
commit c376035
Showing
8 changed files
with
55 additions
and
36 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
27 changes: 0 additions & 27 deletions
27
src/functionalTest/java/uk/gov/hmcts/opal/steps/BearerTokenStefDef.java
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/functionalTest/java/uk/gov/hmcts/opal/steps/BearerTokenStepDef.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,45 @@ | ||
package uk.gov.hmcts.opal.steps; | ||
|
||
import io.cucumber.java.BeforeAll; | ||
import io.cucumber.java.en.When; | ||
import net.serenitybdd.rest.SerenityRest; | ||
|
||
import static net.serenitybdd.rest.SerenityRest.then; | ||
|
||
|
||
public class BearerTokenStepDef extends BaseStepDef { | ||
protected static String TOKEN; | ||
protected static ThreadLocal<String> ALT_TOKEN = new ThreadLocal<>(); | ||
|
||
@BeforeAll | ||
public static void setToken() { | ||
SerenityRest.given() | ||
.accept("*/*") | ||
.contentType("application/json") | ||
.when() | ||
.get(getTestUrl() + "/api/testing-support/token/test-user"); | ||
then().assertThat().statusCode(200); | ||
TOKEN = then().extract().body().jsonPath().getString("access_token"); | ||
} | ||
|
||
protected static String getToken() { | ||
if (ALT_TOKEN.get() == null) { | ||
return TOKEN; | ||
} else { | ||
return ALT_TOKEN.get(); | ||
} | ||
} | ||
|
||
@When("I am testing as the {string} user") | ||
public void setTokenWithUser(String user) { | ||
SerenityRest.given() | ||
.accept("*/*") | ||
.header("X-User-Email", user) | ||
.contentType("application/json") | ||
.when() | ||
.get(getTestUrl() + "/api/testing-support/token/user"); | ||
then().assertThat().statusCode(200); | ||
ALT_TOKEN.set(then().extract().body().jsonPath().getString("access_token")); | ||
} | ||
|
||
} |
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
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