Skip to content

Commit

Permalink
Merge branch 'testing-new-iterations' of https://github.com/Matte22/s…
Browse files Browse the repository at this point in the history
…tig-manager into testing-new-iterations
  • Loading branch information
Matte22 committed Sep 3, 2024
2 parents ae89177 + f92bda9 commit 90618ac
Show file tree
Hide file tree
Showing 17 changed files with 197 additions and 190 deletions.
1 change: 0 additions & 1 deletion test/api/mocha/data/asset/assetDelete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ describe('DELETE - Asset', function () {
this.timeout(4000)
await utils.loadAppData()
await utils.uploadTestStigs()
await utils.createDisabledCollectionsandAssets()
})
it('Delete an Asset in test collection', async function () {

Expand Down
2 changes: 1 addition & 1 deletion test/api/mocha/data/collection/collectionGet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ describe('GET - Collection', function () {

it('Return stig-asset grants for a lvl1 iteration in this collection.',async function () {
const res = await chai.request(config.baseUrl)
.get(`/collections/${reference.testCollection.collectionId}/grants/${reference.grantCheckUserId}/access`)
.get(`/collections/${reference.testCollection.collectionId}/grants/${reference.testCollection.grantCheckUserId}/access`)
.set('Authorization', `Bearer ${iteration.token}`)
if (distinct.grant === "none"){
expect(res).to.have.status(403)
Expand Down
2 changes: 0 additions & 2 deletions test/api/mocha/data/collection/collectionPost.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ describe('POST - Collection - not all tests run for all iterations', function ()
// this.timeout(4000)
await utils.uploadTestStigs()
await utils.loadAppData()
await utils.createDisabledCollectionsandAssets()
})

it("export entire asset to another collection, should create asset in destination",async function () {
Expand Down Expand Up @@ -311,7 +310,6 @@ describe('POST - Collection - not all tests run for all iterations', function ()
this.timeout(4000)
await utils.uploadTestStigs()
await utils.loadAppData()
await utils.createDisabledCollectionsandAssets()
})

it("Set revision v1r1 of test benchmark to assets",async function () {
Expand Down
55 changes: 0 additions & 55 deletions test/api/mocha/data/review/referenceData.js

This file was deleted.

7 changes: 3 additions & 4 deletions test/api/mocha/data/review/reviewDelete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config = require('../../testConfig.json')
const utils = require('../../utils/testUtils')
const iterations = require('../../iterations.js')
const expectations = require('./expectations.js')
const reference = require('./referenceData.js')
const reference = require('../../referenceData.js')

describe('DELETE - Review', () => {

Expand Down Expand Up @@ -58,14 +58,13 @@ describe('DELETE - Review', () => {
this.timeout(4000)
await utils.loadAppData()
await utils.uploadTestStigs()
await utils.createDisabledCollectionsandAssets()
})

it('Delete one metadata key/value of a Review', async () => {
const res = await chai.request(config.baseUrl)
.delete(`/collections/${reference.testCollection.collectionId}/reviews/${reference.testAsset.assetId}/${reference.testAsset.testRuleId}/metadata/keys/${reference.testCollection.collectionMetadataKey}`)
.delete(`/collections/${reference.testCollection.collectionId}/reviews/${reference.testAsset.assetId}/${reference.testAsset.testRuleId}/metadata/keys/${reference.reviewMetadataKey}`)
.set('Authorization', `Bearer ${iteration.token}`)
.send(`${JSON.stringify(reference.testCollection.collectionMetadataValue)}`)
.send(`${JSON.stringify(reference.reviewMetadataValue)}`)
if(iteration.name === 'collectioncreator') {
expect(res).to.have.status(403)
return
Expand Down
32 changes: 16 additions & 16 deletions test/api/mocha/data/review/reviewGet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const expect = chai.expect
const config = require('../../testConfig.json')
const utils = require('../../utils/testUtils')
const expectations = require('./expectations.js')
const reference = require('./referenceData.js')
const reference = require('../../referenceData.js')
const iterations = require('../../iterations.js')

describe('GET - Review', () => {
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('GET - Review', () => {
})
it('Return a list of reviews accessible to the requester, metadata Projection.', async () => {
const res = await chai.request(config.baseUrl)
.get(`/collections/${reference.testCollection.collectionId}/reviews?projection=rule&projection=stigs&metadata=${reference.testCollection.metadataKey}%3A${reference.testCollection.metadataValue}&projection=metadata`)
.get(`/collections/${reference.testCollection.collectionId}/reviews?projection=rule&projection=stigs&metadata=${reference.reviewMetadataKey}%3A${reference.reviewMetadataValue}&projection=metadata`)
.set('Authorization', `Bearer ${iteration.token}`)
if(iteration.name === 'collectioncreator') {
expect(res).to.have.status(403)
Expand All @@ -108,8 +108,8 @@ describe('GET - Review', () => {

for(let review of res.body){
expect(review.metadata).to.be.an('object')
expect(review.metadata).to.have.property(reference.testCollection.metadataKey)
expect(review.metadata[reference.testCollection.metadataKey]).to.be.equal(reference.testCollection.metadataValue)
expect(review.metadata).to.have.property(reference.reviewMetadataKey)
expect(review.metadata[reference.reviewMetadataKey]).to.be.equal(reference.reviewMetadataValue)
}
})
it('Return a list of reviews accessible to the requester, result projection fail only', async () => {
Expand Down Expand Up @@ -198,7 +198,7 @@ describe('GET - Review', () => {

}
if(review.ruleId === reference.testAsset.testRuleId){
expect(review.metadata, "metadata").to.eql({[reference.testAsset.metadataKey]: reference.testAsset.metadataValue})
expect(review.metadata, "metadata").to.eql({[reference.reviewMetadataKey]: reference.reviewMetadataValue})
expect(review.status.label, "expect review to be submitted").to.be.oneOf(['submitted'])
expect(review.result, "expect result to be pass").to.eql('pass')
for(const stig of review.stigs){
Expand Down Expand Up @@ -231,7 +231,7 @@ describe('GET - Review', () => {
expect(stig.benchmarkId).to.be.equal(reference.testCollection.benchmark)
}
if(review.ruleId === reference.testAsset.testRuleId){
expect(review.metadata, "metadata").to.eql({[reference.testAsset.metadataKey]: reference.testAsset.metadataValue})
expect(review.metadata, "metadata").to.eql({[reference.reviewMetadataKey]: reference.reviewMetadataValue})
expect(review.status.label, "expect review to be submitted").to.be.oneOf(['submitted'])
expect(review.result, "expect result to be pass").to.eql('pass')
for(const stig of review.stigs){
Expand All @@ -244,7 +244,7 @@ describe('GET - Review', () => {
})
it('Return a list of Reviews for an Asset , metadata Projection.', async () => {
const res = await chai.request(config.baseUrl)
.get(`/collections/${reference.testCollection.collectionId}/reviews/${reference.testAsset.assetId}?projection=rule&projection=stigs&metadata=${reference.testAsset.metadataKey}%3A${reference.testAsset.metadataValue}&projection=metadata`)
.get(`/collections/${reference.testCollection.collectionId}/reviews/${reference.testAsset.assetId}?projection=rule&projection=stigs&metadata=${reference.reviewMetadataKey}%3A${reference.reviewMetadataValue}&projection=metadata`)
.set('Authorization', `Bearer ${iteration.token}`)
if(iteration.name === 'collectioncreator') {
expect(res).to.have.status(403)
Expand All @@ -257,8 +257,8 @@ describe('GET - Review', () => {
for(let review of res.body){
expect(review.assetId).to.be.equal(reference.testAsset.assetId)
expect(review.metadata).to.be.an('object')
expect(review.metadata).to.have.property(reference.testCollection.metadataKey)
expect(review.metadata[reference.testCollection.metadataKey]).to.be.equal(reference.testCollection.metadataValue)
expect(review.metadata).to.have.property(reference.reviewMetadataKey)
expect(review.metadata[reference.reviewMetadataKey]).to.be.equal(reference.reviewMetadataValue)
}
})
it('Return a list of reviews accessible to the requester, result projection pass only', async () => {
Expand Down Expand Up @@ -367,8 +367,8 @@ describe('GET - Review', () => {

// checking for basic properties
expect(review.rule.ruleId).to.be.equal(reference.testCollection.ruleId)
expect(review.metadata).to.have.property(reference.testCollection.metadataKey)
expect(review.metadata[reference.testCollection.metadataKey]).to.be.equal(reference.testCollection.metadataValue)
expect(review.metadata).to.have.property(reference.reviewMetadataKey)
expect(review.metadata[reference.reviewMetadataKey]).to.be.equal(reference.reviewMetadataValue)
for(let stig of review.stigs){
expect(stig.benchmarkId, "expect stig attached to be test bernchmark").to.be.equal(reference.benchmark)
expect(stig.ruleCount, "Expect 81 rules for vpn srg test").to.be.equal(reference.checklistLength)
Expand All @@ -391,8 +391,8 @@ describe('GET - Review', () => {
}
expect(res).to.have.status(200)
expect(res.body).to.be.an('object')
expect(res.body).to.have.property(reference.testAsset.metadataKey)
expect(res.body[reference.testAsset.metadataKey]).to.be.equal(reference.testAsset.metadataValue)
expect(res.body).to.have.property(reference.reviewMetadataKey)
expect(res.body[reference.reviewMetadataKey]).to.be.equal(reference.reviewMetadataValue)
})
})
describe('GET - getReviewMetadataKeys - /collections/{collectionId}/reviews/{assetId}/{ruleId}/metadata/keys', () => {
Expand All @@ -408,22 +408,22 @@ describe('GET - Review', () => {
expect(res).to.have.status(200)
expect(res.body).to.be.an('array')
expect(res.body).to.be.lengthOf(1)
expect(res.body).to.include(reference.testAsset.metadataKey)
expect(res.body).to.include(reference.reviewMetadataKey)
})
})
describe('GET - getReviewMetadataValue - /collections/{collectionId}/reviews/{assetId}/{ruleId}/metadata/keys/{key}', () => {

it('Return the Review Metadata VALUE for an Asset/Rule/metadata KEY', async () => {
const res = await chai.request(config.baseUrl)
.get(`/collections/${reference.testCollection.collectionId}/reviews/${reference.testAsset.assetId}/${reference.testCollection.ruleId}/metadata/keys/${reference.testAsset.metadataKey}`)
.get(`/collections/${reference.testCollection.collectionId}/reviews/${reference.testAsset.assetId}/${reference.testCollection.ruleId}/metadata/keys/${reference.reviewMetadataKey}`)
.set('Authorization', `Bearer ${iteration.token}`)
if(iteration.name === 'collectioncreator') {
expect(res).to.have.status(403)
return
}
expect(res).to.have.status(200)
expect(res.body).to.be.an('string')
expect(res.body).to.equal(reference.testAsset.metadataValue)
expect(res.body).to.equal(reference.reviewMetadataValue)
})
})
})
Expand Down
17 changes: 8 additions & 9 deletions test/api/mocha/data/review/reviewPatch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ chai.use(chaiHttp)
const expect = chai.expect
const config = require('../../testConfig.json')
const utils = require('../../utils/testUtils')
const reference = require('./referenceData.js')
const reference = require('../../referenceData.js')
const iterations = require('../../iterations.js')
const expectations = require('./expectations.js')

Expand Down Expand Up @@ -121,23 +121,22 @@ describe('PATCH - Review', () => {

describe('PATCH - patchReviewMetadata - /collections/{collectionId}/reviews/{assetId}/{ruleId}/metadata', () => {

before(async function () {
this.timeout(4000)
await utils.loadAppData()
await utils.uploadTestStigs()
await utils.createDisabledCollectionsandAssets()
})
// before(async function () {
// this.timeout(4000)
// await utils.loadAppData()
// await utils.uploadTestStigs()
// })
it('Merge metadata property/value into a Review', async () => {
const res = await chai.request(config.baseUrl)
.patch(`/collections/${reference.testCollection.collectionId}/reviews/${reference.testAsset.assetId}/${reference.testCollection.ruleId}/metadata`)
.set('Authorization', `Bearer ${iteration.token}`)
.send({[reference.testCollection.metadataKey]: reference.testCollection.metadataValue})
.send({[reference.reviewMetadataKey]: reference.reviewMetadataValue})
if(iteration.name === 'collectioncreator') {
expect(res).to.have.status(403)
return
}
expect(res).to.have.status(200)
expect(res.body).to.eql({[reference.testCollection.metadataKey]: reference.testCollection.metadataValue})
expect(res.body).to.eql({[reference.reviewMetadataKey]: reference.reviewMetadataValue})

})
})
Expand Down
5 changes: 3 additions & 2 deletions test/api/mocha/data/review/reviewPost.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config = require('../../testConfig.json')
const utils = require('../../utils/testUtils')
const iterations = require('../../iterations.js')
const expectations = require('./expectations.js')
const reference = require('./referenceData.js')
const reference = require('../../referenceData.js')

const checkReviews = (reviews, postreview, iteration) => {
for(let review of reviews){
Expand Down Expand Up @@ -826,8 +826,8 @@ describe('POST - Review', () => {
this.timeout(4000)
await utils.uploadTestStigs()
await utils.loadAppData("batch-test-data.json")
await utils.createDisabledCollectionsandAssets()
})

it(`POST batch Review: target by assets, and one rule, expect validation failure - invalid result for status`, async () => {
const postreview = {
source: {
Expand Down Expand Up @@ -873,6 +873,7 @@ describe('POST - Review', () => {
}

})

it(`POST batch Review: target by stig, and one rule, expect validation failure - fail result, no comment`, async () => {
const postreview = {
source: {
Expand Down
Loading

0 comments on commit 90618ac

Please sign in to comment.