Skip to content

Commit

Permalink
Merge pull request #2593 from NationalSecurityAgency/t#2490/primevue-…
Browse files Browse the repository at this point in the history
…pkiTests

T#2490/primevue pki tests
  • Loading branch information
sudo-may authored Jun 19, 2024
2 parents cf1b648 + a1ded00 commit b24eb07
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/runSubsetOfServiceTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if (( ${#integrationTests[@]} != 0 )); then
fi

if [ "$cachingSpec" == 'yes' ]; then
echo 'Found CachingSpec. Building dashboard & client-display...'
echo 'Found CachingSpec. Building dashboard'
cd ../dashboard-prime
npm run deploy
# cd ../client-display
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test-email-confirmation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ jobs:
repository: NationalSecurityAgency/skills-client
path: skills-client

- uses: actions/setup-node@v2-beta
- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '20.11.0'

- uses: actions/setup-java@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test-night-service-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '20.11.0'

- uses: actions/setup-java@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test-rabbitmq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ jobs:

- uses: actions/checkout@v2

- uses: actions/setup-node@v2-beta
- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '20.11.0'

- uses: actions/setup-java@v1
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-and-test-ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
schedule:
- cron: '0 7 * * *'
workflow_dispatch:
push:
# pull_request:
# paths-ignore:
# - 'README.md'
Expand Down Expand Up @@ -60,7 +61,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '20.11.0'

- uses: actions/setup-java@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '20.11.0'

- uses: actions/setup-java@v3
with:
Expand Down
83 changes: 13 additions & 70 deletions service/src/test/java/skills/intTests/CachingSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
*/
package skills.intTests

import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.core.io.ResourceLoader
import org.springframework.core.io.support.ResourcePatternUtils
import org.springframework.http.ResponseEntity
import skills.intTests.utils.DefaultIntSpec

@Slf4j
class CachingSpec extends DefaultIntSpec {

@Autowired
Expand Down Expand Up @@ -83,81 +85,22 @@ class CachingSpec extends DefaultIntSpec {
def "assets should be cached"() {
when:
int count = 0
getFileNamesFromClasspath("/public/assets/**").each {
println it
ResponseEntity<String> responseEntity = skillsService.wsHelper.rawGet("/assets/${it}", [:])
assert responseEntity.statusCode.is2xxSuccessful()
assert responseEntity.headers.getCacheControl() == "max-age=${defaultCacheAge}, must-revalidate, private"
count++
}
List<String> ignore = ["dashboard-prime"]
getFileNamesFromClasspath("/public/assets/**")
.findAll { !ignore.contains(it) }
.each {
String endpoint = "/assets/${it}".toString()
log.info("Checking endpoint: [${endpoint}]")
ResponseEntity<String> responseEntity = skillsService.wsHelper.rawGet(endpoint, [:])
assert responseEntity.statusCode.is2xxSuccessful(), "Failed for [${endpoint}] endpoint"
assert responseEntity.headers.getCacheControl() == "max-age=${defaultCacheAge}, must-revalidate, private", "Failed for [${endpoint}] endpoint"
count++
}

then:
count > 0
}

// TODO: add back
// def "clientPortal index page should not be cached"() {
// when:
// ResponseEntity<String> responseEntity = skillsService.wsHelper.rawGet("assets/clientPortal/index.html", [:])
//
// then:
// responseEntity.statusCode.is2xxSuccessful()
// responseEntity.headers.getCacheControl() == "no-store"
// }
//
// def "clientPortal js resources should be cached"() {
// when:
//
// getFileNamesFromClasspath("/public/assets/clientPortal/js/**").each {
// ResponseEntity<String> responseEntity = skillsService.wsHelper.rawGet("/assets/clientPortal/js/${it}", [:])
// assert responseEntity.statusCode.is2xxSuccessful()
// assert responseEntity.headers.getCacheControl() == "max-age=7776000, must-revalidate, private"
// }
//
// then:
// true
// }
//
// def "clientPortal img resources should be cached"() {
// when:
//
// getFileNamesFromClasspath("/public/assets/clientPortal/img/**").each {
// ResponseEntity<String> responseEntity = skillsService.wsHelper.rawGet("/assets/clientPortal/img/${it}", [:])
// assert responseEntity.statusCode.is2xxSuccessful()
// assert responseEntity.headers.getCacheControl() == "max-age=1209600, must-revalidate, private"
// }
//
// then:
// true
// }
//
// def "clientPortal fonts resources should be cached"() {
// when:
//
// getFileNamesFromClasspath("/public/assets/clientPortal/fonts/**").each {
// ResponseEntity<String> responseEntity = skillsService.wsHelper.rawGet("/assets/clientPortal/fonts/${it}", [:])
// assert responseEntity.statusCode.is2xxSuccessful()
// assert responseEntity.headers.getCacheControl() == "max-age=1209600, must-revalidate, private"
// }
//
// then:
// true
// }
//
// def "clientPortal css resources should be cached"() {
// when:
//
// getFileNamesFromClasspath("/public/assets/clientPortal/css/**").each {
// ResponseEntity<String> responseEntity = skillsService.wsHelper.rawGet("/assets/clientPortal/css/${it}", [:])
// assert responseEntity.statusCode.is2xxSuccessful()
// assert responseEntity.headers.getCacheControl() == "max-age=7776000, must-revalidate, private"
// }
//
// then:
// true
// }


private getFileNamesFromClasspath(String classpathPath) {
return ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources("classpath:${classpathPath}").collect {
it.filename
Expand Down

0 comments on commit b24eb07

Please sign in to comment.