-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08440d1
commit d5d7060
Showing
2 changed files
with
39 additions
and
9 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
36 changes: 36 additions & 0 deletions
36
skill-tree/src/test/java/com/RDS/skilltree/SecurityContextIntegrationTest.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,36 @@ | ||
package com.RDS.skilltree; | ||
|
||
import io.restassured.response.Response; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import utils.RestAPIHelper; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.Matchers.*; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) | ||
public class SecurityContextIntegrationTest extends TestContainerManager { | ||
|
||
@Test | ||
public void testTokenIsNotPresent() { | ||
|
||
Response response = given().get("/v1/health"); | ||
response.then().statusCode(401).body("message", equalTo("The access token provided is expired, revoked, malformed, or invalid for other reasons.Full authentication is required to access this resource")); | ||
} | ||
|
||
@Test | ||
public void testInvalidToken() { | ||
|
||
Response response = given().cookie("rds-session-v2", "invalidtoken").get("/v1/health"); | ||
response.then().statusCode(401).body("message", equalTo("The access token provided is expired, revoked, malformed, or invalid for other reasons.Full authentication is required to access this resource")); | ||
} | ||
|
||
@Test | ||
public void testValidToken() { | ||
|
||
Response response = given().cookies(RestAPIHelper.getUserCookie()).get("/v1/health"); | ||
response.then().statusCode(200); | ||
} | ||
} |