Skip to content

Commit

Permalink
Rework token service mocking for test #3421
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Jan 29, 2025
1 parent 10452ec commit 131ec37
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class ParatooIntegrationSpec extends StubbedCasSpec implements GrailsUnitTest {
String token = tokenForUser('1')
AccessToken accessToken = new BearerAccessToken(token)
TokenService tokenService = Stub(TokenService)
tokenService.getAuthToken(_) >> accessToken
tokenService.getAuthToken(true) >> accessToken

String m2mToken = setupTokenForSystem()
AccessToken m2mAccessToken = new BearerAccessToken(m2mToken)
tokenService.getAuthToken(false) >> m2mAccessToken
webService = new WebService(grailsApplication: getGrailsApplication(), tokenService: tokenService)
}

Expand Down Expand Up @@ -138,7 +142,7 @@ class ParatooIntegrationSpec extends StubbedCasSpec implements GrailsUnitTest {
when:
collectionPayload.orgMintedUUID = orgMintedUUID
url = testConfig.ecodata.baseUrl + '/paratoo/collection'
resp = webService.post(url, collectionPayload, null, ContentType.APPLICATION_JSON, false, false, headers)
resp = webService.post(url, collectionPayload, null, ContentType.APPLICATION_JSON, true, false, headers)

then:
resp.statusCode == HttpStatus.SC_OK
Expand Down Expand Up @@ -181,6 +185,7 @@ class ParatooIntegrationSpec extends StubbedCasSpec implements GrailsUnitTest {
}
executor.invokeAll(callables)


String url = testConfig.ecodata.baseUrl + 'project/'+projectId
Map resp = webService.get(url, [:], ContentType.APPLICATION_JSON, true, false)

Expand Down

0 comments on commit 131ec37

Please sign in to comment.