Skip to content
Snippets Groups Projects
Verified Commit 7acdff6d authored by Ira ¯\_(ツ)_/¯'s avatar Ira ¯\_(ツ)_/¯
Browse files

Change name to be more apparent which user is being used during testing

parent 9f757dcb
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ public class MailPassResourceIntegrationTest {
private final static String ROOT_URI = "http://localhost:{0,number,#}/auth/realms/master/mailpass/roleauth";
private final static String TOKEN_GEN_URI = "http://localhost:{0,number,#}/auth/realms/master/protocol/openid-connect/token";
private static String token;
private static String adminToken;
private static int port;
@ClassRule
......@@ -36,19 +36,19 @@ public class MailPassResourceIntegrationTest {
.body("grant_type=password&username=admin&password=admin&client_id=admin-cli")
.post(MessageFormat.format(TOKEN_GEN_URI, port));
token = response.jsonPath().getString("access_token");
adminToken = response.jsonPath().getString("access_token");
}
@Test
public void testNonAuthenticatedAccessReturns401() {
public void testNonAuthenticatedAccessReturnsUnauthorized401() {
Response response = given().contentType(ContentType.JSON).body("{ \"password\": \"password\" }").when()
.post(MessageFormat.format(ROOT_URI, port) + "/compute-password-hash");
assertEquals(401, response.getStatusCode());
}
@Test
public void testAuthenticatedAccessReturns200() {
Response response = given().header("Authorization", "Bearer " + token).contentType(ContentType.JSON)
public void testAuthenticatedAccessReturnsCreated200() {
Response response = given().header("Authorization", "Bearer " + adminToken).contentType(ContentType.JSON)
.body("{ \"password\": \"password\" }").when()
.post(MessageFormat.format(ROOT_URI, port) + "/compute-password-hash");
assertEquals(201, response.getStatusCode());
......@@ -56,7 +56,7 @@ public class MailPassResourceIntegrationTest {
@Test
public void testMalformedJsonRaisesBadRequestException400() {
Response response = given().header("Authorization", "Bearer " + token).contentType(ContentType.JSON)
Response response = given().header("Authorization", "Bearer " + adminToken).contentType(ContentType.JSON)
.body("{ \"password\"x \"password\" }").when()
.post(MessageFormat.format(ROOT_URI, port) + "/compute-password-hash");
assertEquals(400, response.getStatusCode());
......@@ -64,7 +64,7 @@ public class MailPassResourceIntegrationTest {
@Test
public void testMalformedJsonExceptionMessage() {
Response response = given().header("Authorization", "Bearer " + token).contentType(ContentType.JSON)
Response response = given().header("Authorization", "Bearer " + adminToken).contentType(ContentType.JSON)
.body("{ \"password\"x \"password\" }").when()
.post(MessageFormat.format(ROOT_URI, port) + "/compute-password-hash");
......@@ -75,7 +75,7 @@ public class MailPassResourceIntegrationTest {
@Test
public void testMissingJsonObjectRaisesBadRequestException400() {
Response response = given().header("Authorization", "Bearer " + token).contentType(ContentType.JSON)
Response response = given().header("Authorization", "Bearer " + adminToken).contentType(ContentType.JSON)
.body("{ \"missing_password\": \"password\" }").when()
.post(MessageFormat.format(ROOT_URI, port) + "/compute-password-hash");
assertEquals(400, response.getStatusCode());
......@@ -83,7 +83,7 @@ public class MailPassResourceIntegrationTest {
@Test
public void testMissingJsonObjectExceptionMessage() {
Response response = given().header("Authorization", "Bearer " + token).contentType(ContentType.JSON)
Response response = given().header("Authorization", "Bearer " + adminToken).contentType(ContentType.JSON)
.body("{ \"missing_password\": \"password\" }").when()
.post(MessageFormat.format(ROOT_URI, port) + "/compute-password-hash");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment