Skip to content

Commit

Permalink
#1612 Fixed tests, removed unused dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian-Olosutean committed Dec 18, 2020
1 parent 17b19e1 commit 8cb6521
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ abstract class AuthClientSuite() extends AnyWordSpec

s"Calling authenticate()" should {
"return authentication headers on 200 OK" in {
val sessionCookie = "session-cookie"
val jwt = "jwt"
val csrfToken = "csrf-token"

val responseHeaders = new LinkedMultiValueMap[String, String]
responseHeaders.add("set-cookie", sessionCookie)
responseHeaders.add("jwt", jwt)
responseHeaders.add("x-csrf-token", csrfToken)

setUpSuccessfulAuthRequest(responseHeaders)

val expected = new HttpHeaders()
expected.add("cookie", sessionCookie)
expected.add("jwt", jwt)
expected.add("x-csrf-token", csrfToken)

val response = authClient.authenticate()
Expand Down
5 changes: 0 additions & 5 deletions menas-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang.modules</groupId>
<artifactId>scala-xml_${scala.compat.version}</artifactId>
<version>${scala.xml.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AuthenticationIntegrationSuite extends BaseRestApiTest {
@Autowired
val jwtFactory: JwtFactory = null

private val jwtRegex = "JWT=([^;]+);?.*".r
private val jwtRegex = "([^;]+);?.*".r

"Username and password authentication" should {
"handle multiple users login in concurrently" in {
Expand All @@ -50,7 +50,7 @@ class AuthenticationIntegrationSuite extends BaseRestApiTest {

val results = Await.result(futures, awaitDuration)
val usernames = results.map { headers =>
headers.get("cookie").get(0) match {
headers.get("jwt").get(0) match {
case jwtRegex(jwt) =>
jwtFactory.jwtParser()
.parseClaimsJws(jwt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ abstract class BaseRestApiTest extends BaseRepositoryTest {

val response = restTemplate.postForEntity(loginUrl, HttpEntity.EMPTY, classOf[String])

val cookie = response.getHeaders.get("set-cookie").get(0)
val jwtToken = response.getHeaders.get("jwt").get(0)
val csrfToken = response.getHeaders.get("X-CSRF-TOKEN").get(0)
val headers = new HttpHeaders()
headers.add("cookie", cookie)
headers.add("jwt", jwtToken)
headers.add("X-CSRF-TOKEN", csrfToken)
headers
}
Expand Down

0 comments on commit 8cb6521

Please sign in to comment.