diff --git a/test/api/mocha/data/asset/assetPatch.test.js b/test/api/mocha/data/asset/assetPatch.test.js index 6a97c2b9..57166157 100644 --- a/test/api/mocha/data/asset/assetPatch.test.js +++ b/test/api/mocha/data/asset/assetPatch.test.js @@ -9,6 +9,10 @@ const expectations = require('./expectations.js') const reference = require('../../referenceData.js') describe('PATCH - Asset', function () { + + before(async () => { + await utils.loadAppData() + }) after(async () => { await utils.resetTestAsset() @@ -23,11 +27,13 @@ describe('PATCH - Asset', function () { describe(`iteration:${iteration.name}`, function () { const distinct = expectations[iteration.name] - + let testAsset = null + let scrapAsset = null beforeEach(async function () { + this.timeout(4000) - await utils.resetTestAsset() - await utils.resetScrapAsset() + testAsset = await utils.resetTestAsset() + scrapAsset = await utils.resetScrapAsset() }) describe(`updateAsset - /assets/{assetId}`, function () { diff --git a/test/api/mocha/data/collection/collectionDelete.test.js b/test/api/mocha/data/collection/collectionDelete.test.js index bd14fbad..663f166f 100644 --- a/test/api/mocha/data/collection/collectionDelete.test.js +++ b/test/api/mocha/data/collection/collectionDelete.test.js @@ -10,18 +10,15 @@ const utils = require('../../utils/testUtils') const iterations = require('../../iterations') const expectations = require('./expectations') const reference = require('../../referenceData.js') +const requestBodies = require('./requestBodies') describe('DELETE - Collection ', function () { - before(async function () { - this.timeout(4000) - await utils.uploadTestStigs() - }) + let tempCollection = null - beforeEach(async function () { - this.timeout(4000) - await utils.loadAppData() - }) + // before(async function () { + // await utils.loadAppData() + // }) for(const iteration of iterations){ @@ -34,45 +31,17 @@ describe('DELETE - Collection ', function () { const distinct = expectations[iteration.name] describe('deleteCollection - /collections/{collectionId}', function () { - if (iteration.name === 'stigmanadmin' ){ - it('Delete test Collection, test projections - elevated stigmanadmin only',async function () { - const res = await chai.request(config.baseUrl) - .delete(`/collections/${reference.testCollection.collectionId}?elevate=true&projection=assets&projection=grants&projection=owners&projection=statistics&projection=stigs`) - .set('Authorization', `Bearer ${iteration.token}`) - - expect(res).to.have.status(200) - expect(res.body.collectionId).to.equal(reference.testCollection.collectionId) - - expect(res.body.assets).to.have.lengthOf(reference.testCollection.assetIds.length) - for(const asset of res.body.assets){ - expect(reference.testCollection.assetIds).to.include(asset.assetId) - } - expect(res.body.grants).to.have.lengthOf(reference.testCollection.grantsProjected.length) - for(const grant of res.body.grants){ - const userIds = reference.testCollection.grantsProjected.map(grant => grant.user.userId) - expect(userIds).to.include(grant.user.userId) - } - - expect(res.body.owners).to.have.lengthOf(reference.testCollection.owners.length) - for(const owner of res.body.owners){ - expect(reference.testCollection.owners).to.include(owner.userId) - } - - expect(res.body.stigs).to.have.lengthOf(reference.testCollection.validStigs.length) - for(const stig of res.body.stigs){ - expect(reference.testCollection.validStigs).to.include(stig.benchmarkId) - } + before(async function () { + const testCollectionClone = JSON.parse(JSON.stringify(requestBodies.resetTestCollection)) + testCollectionClone.name = `Collection ` + Math.floor(Math.random() * 1000000) + tempCollection = await utils.createTempCollection(testCollectionClone) + console.log(`tempCollection: ${tempCollection.data.collectionId}`) + }) - expect(res.body.statistics).to.have.property('assetCount', reference.testCollection.assetIds.length) - expect(res.body.statistics).to.have.property('grantCount', reference.testCollection.grantsProjected.length) - const deletedCollection = await utils.getCollection(reference.testCollection.collectionId) - expect(deletedCollection).to.be.undefined - }) - } - it('Delete deleteCollection collection (stigmanadmin only)',async function () { + it('Delete tempCollection collection (stigmanadmin only)',async function () { const res = await chai.request(config.baseUrl) - .delete(`/collections/${reference.deleteCollection.collectionId}`) + .delete(`/collections/${tempCollection.data.collectionId}`) .set('Authorization', `Bearer ${iteration.token}`) if(distinct.canDeleteCollection === false){ @@ -81,27 +50,34 @@ describe('DELETE - Collection ', function () { } expect(res).to.have.status(200) - expect(res.body.collectionId).to.equal(reference.deleteCollection.collectionId) + expect(res.body.collectionId).to.equal(tempCollection.data.collectionId) //confirm that it is deleted - const deletedCollection = await utils.getCollection(reference.deleteCollection.collectionId) + const deletedCollection = await utils.getCollection(tempCollection.data.collectionId) expect(deletedCollection).to.be.undefined }) + }) describe('deleteCollectionLabelById - /collections/{collectionId}/labels/{labelId}', function () { + let tempLabel = null + beforeEach(async function () { + const labelPost = JSON.parse(JSON.stringify(requestBodies.recreateCollectionLabel)) + labelPost.name = `Label ` + Math.floor(Math.random() * 1000000) + tempLabel = await utils.createCollectionLabel(reference.testCollection.collectionId, labelPost) + }) it('Delete a scrap collection scrap Label',async function () { const res = await chai.request(config.baseUrl) - .delete(`/collections/${reference.scrapCollection.collectionId}/labels/${reference.scrapCollection.scrapLabel}`) + .delete(`/collections/${reference.testCollection.collectionId}/labels/${tempLabel.labelId}`) .set('Authorization', `Bearer ${iteration.token}`) if(distinct.canModifyCollection === false){ expect(res).to.have.status(403) return } expect(res).to.have.status(204) - const collection = await utils.getCollection(reference.scrapCollection.collectionId) - expect(collection.labels).to.not.include(reference.scrapCollection.scrapLabel) + const collection = await utils.getCollection(reference.testCollection.collectionId) + expect(collection.labels).to.not.include(tempLabel.labelId) }) it("should throw SmError.NotFoundError when deleting a non-existent label.",async function () { const labelId = uuidv4() @@ -119,24 +95,30 @@ describe('DELETE - Collection ', function () { describe('deleteCollectionMetadataKey - /collections/{collectionId}/metadata/keys/{key}', function () { + beforeEach(async function () { + const res = await utils.putCollection(reference.testCollection.collectionId, requestBodies.resetTestCollection) + }) it('Delete a scrap collection Metadata Key',async function () { const res = await chai.request(config.baseUrl) - .delete(`/collections/${reference.scrapCollection.collectionId}/metadata/keys/${reference.scrapCollection.collectionMetadataKey}`) + .delete(`/collections/${reference.testCollection.collectionId}/metadata/keys/${reference.testCollection.collectionMetadataKey}`) .set('Authorization', `Bearer ${iteration.token}`) if(distinct.canModifyCollection === false){ expect(res).to.have.status(403) return } - expect(res).to.have.status(204) - const collection = await utils.getCollection(reference.scrapCollection.collectionId) - expect(collection.metadata).to.not.have.property(reference.scrapCollection.collectionMetadataKey) + const collection = await utils.getCollection(reference.testCollection.collectionId) + expect(collection.metadata).to.not.have.property(reference.testCollection.collectionMetadataKey) }) }) describe('deleteReviewHistoryByCollection - /collections/{collectionId}/review-history', function () { + beforeEach(async function () { + await utils.loadAppData() + }) + it('Delete review History records - retentionDate',async function () { const res = await chai.request(config.baseUrl) .delete(`/collections/${reference.testCollection.collectionId}/review-history?retentionDate=${reference.testCollection.reviewHistory.endDate}`) @@ -150,7 +132,6 @@ describe('DELETE - Collection ', function () { expect(res).to.have.status(200) expect(res.body.HistoryEntriesDeleted).to.be.equal(reference.testCollection.reviewHistory.deletedEntriesByDate) }) - it('Delete review History records - date and assetId',async function () { const res = await chai.request(config.baseUrl) .delete(`/collections/${reference.testCollection.collectionId}/review-history?retentionDate=${reference.testCollection.reviewHistory.endDate}&assetId=${reference.testCollection.testAssetId}`) diff --git a/test/api/mocha/data/collection/collectionPatch.test.js b/test/api/mocha/data/collection/collectionPatch.test.js index ab5a642e..aa26dde9 100644 --- a/test/api/mocha/data/collection/collectionPatch.test.js +++ b/test/api/mocha/data/collection/collectionPatch.test.js @@ -15,7 +15,6 @@ describe('PATCH - Collection', function () { before(async function () { this.timeout(4000) await utils.uploadTestStigs() - await utils.loadAppData() }) for(const iteration of iterations) { @@ -27,12 +26,17 @@ describe('PATCH - Collection', function () { describe(`iteration:${iteration.name}`, function () { + beforeEach(async function () { + await utils.putCollection(reference.testCollection, requestBodies.resetTestCollection) + }) + describe('updateCollection - /collections/{collectionId}', function () { - it('Patch scrap collection, send 5 new grants and metadata.',async function () { + + it('Patch test collection, send 5 new grants and metadata.',async function () { const patchRequest = requestBodies.updateCollection const res = await chai.request(config.baseUrl) - .patch(`/collections/${reference.scrapCollection.collectionId}?&projection=grants&projection=stigs`) + .patch(`/collections/${reference.testCollection.collectionId}?&projection=grants&projection=stigs`) .set('Authorization', `Bearer ${iteration.token}`) .send(patchRequest) @@ -49,7 +53,7 @@ describe('PATCH - Collection', function () { expect(res.body.grants).to.have.lengthOf(patchRequest.grants.length) for(let stig of res.body.stigs) { - expect(stig.benchmarkId).to.be.oneOf(reference.scrapCollection.validStigs) + expect(stig.benchmarkId).to.be.oneOf(reference.testCollection.validStigs) if(stig.benchmarkId === reference.benchmark){ expect(stig.ruleCount).to.equal(reference.checklistLength) } @@ -72,14 +76,12 @@ describe('PATCH - Collection', function () { expect(res.body.error).to.equal("Unprocessable Entity.") expect(res.body.detail).to.equal("Duplicate user in grant array") }) - }) - describe('patchCollectionLabelById - /collections/{collectionId}/labels/{labelId}', function () { - it('Patch scrap collection label, change color, description and name ',async function () { + it('Patch test collection label, change color, description and name ',async function () { const body = requestBodies.patchCollectionLabelById const res = await chai.request(config.baseUrl) - .patch(`/collections/${reference.scrapCollection.collectionId}/labels/${reference.scrapCollection.scrapLabel}`) + .patch(`/collections/${reference.testCollection.collectionId}/labels/${reference.testCollection.fullLabel}`) .set('Authorization', `Bearer ${iteration.token}`) .send(body) @@ -89,7 +91,7 @@ describe('PATCH - Collection', function () { } expect(res).to.have.status(200) - expect(res.body.labelId).to.equal(reference.scrapCollection.scrapLabel) + expect(res.body.labelId).to.equal(reference.testCollection.fullLabel) expect(res.body.description).to.equal(body.description) expect(res.body.color).to.equal(body.color) expect(res.body.name).to.equal(body.name) @@ -98,7 +100,7 @@ describe('PATCH - Collection', function () { const body = requestBodies.patchCollectionLabelById const res = await chai.request(config.baseUrl) - .patch(`/collections/${reference.scrapCollection.collectionId}/labels/${uuidv4()}`) + .patch(`/collections/${reference.testCollection.collectionId}/labels/${uuidv4()}`) .set('Authorization', `Bearer ${iteration.token}`) .send(body) if(distinct.canModifyCollection === false){ @@ -109,15 +111,14 @@ describe('PATCH - Collection', function () { expect(res.body.error).to.equal("Resource not found.") }) }) - describe('patchCollectionMetadata - /collections/{collectionId}/metadata', function () { - it('Patch scrap collection metadata',async function () { + it('Patch test collection metadata',async function () { const res = await chai.request(config.baseUrl) - .patch(`/collections/${reference.scrapCollection.collectionId}/metadata`) + .patch(`/collections/${reference.testCollection.collectionId}/metadata`) .set('Authorization', `Bearer ${iteration.token}`) - .send({[reference.scrapCollection.collectionMetadataKey]: reference.scrapCollection.collectionMetadataValue}) + .send({[reference.testCollection.collectionMetadataKey]: reference.testCollection.collectionMetadataValue}) if(distinct.canModifyCollection === false){ expect(res).to.have.status(403) @@ -125,7 +126,7 @@ describe('PATCH - Collection', function () { } expect(res).to.have.status(200) - expect(res.body).to.contain({[reference.scrapCollection.collectionMetadataKey]: reference.scrapCollection.collectionMetadataValue}) + expect(res.body).to.contain({[reference.testCollection.collectionMetadataKey]: reference.testCollection.collectionMetadataValue}) }) }) }) diff --git a/test/api/mocha/data/collection/collectionPut.test.js b/test/api/mocha/data/collection/collectionPut.test.js index 1bcf3185..d20e4ae6 100644 --- a/test/api/mocha/data/collection/collectionPut.test.js +++ b/test/api/mocha/data/collection/collectionPut.test.js @@ -16,8 +16,7 @@ describe('PUT - Collection', function () { before(async function () { this.timeout(4000) await utils.uploadTestStigs() - await utils.loadAppData() - await utils.createDisabledCollectionsandAssets() + // await utils.createDisabledCollectionsandAssets() }) for(const iteration of iterations){ diff --git a/test/api/mocha/data/collection/requestBodies.js b/test/api/mocha/data/collection/requestBodies.js index 9f3e23a4..5486dd0b 100644 --- a/test/api/mocha/data/collection/requestBodies.js +++ b/test/api/mocha/data/collection/requestBodies.js @@ -138,6 +138,83 @@ const requestBodies = { writeStigPropsByCollectionStig: { defaultRevisionStr: 'V1R1', assetIds: ['62', '42', '154'] - } + }, + resetTestCollection:{ + name: 'Collection X', + description: null, + settings: { + fields: { + detail: { + enabled: 'always', + required: 'always' + }, + comment: { + enabled: 'always', + required: 'findings' + } + }, + status: { + canAccept: true, + minAcceptGrant: 3, + resetCriteria: 'result' + }, + history: { + maxReviews: 5 + } + }, + metadata: { + pocName: 'true', + pocEmail: 'pocEmailPut@email.com', + pocPhone: '12342', + reqRar: 'true' + }, + grants: [ + { + userId: '1', + accessLevel: 4 + }, + { + userId: '45', + accessLevel: 4 + }, + { + userId: '87', + accessLevel: 4 + }, + { + userId: '44', + accessLevel: 3 + }, + { + userId: "21", + accessLevel: 2 + }, + { + userId: "85", + accessLevel: 1 + }, + { + userId: "86", + accessLevel: 1 + } + ], + labels: [ + { + name: 'test-label-full', + description: '', + color: 'FF99CC' + }, + { + name: 'test-label-lvl1', + description: '', + color: '99CCFF' + } + ] + }, + recreateCollectionLabel:{ + name: 'testLabel', + description: 'test label', + color: 'FF99CC' + }, } module.exports = requestBodies diff --git a/test/api/mocha/data/review/reviewGet.test.js b/test/api/mocha/data/review/reviewGet.test.js index 6fba57b4..460eeebb 100644 --- a/test/api/mocha/data/review/reviewGet.test.js +++ b/test/api/mocha/data/review/reviewGet.test.js @@ -249,6 +249,7 @@ describe('GET - Review', () => { expect(review.assetId).to.be.oneOf(reference.testCollection.assetIds) } }) + // this test has some odd behavior . it('Return a list of reviews accessible to the requester, rules=not-default', async () => { const res = await chai.request(config.baseUrl) .get(`/collections/${reference.testCollection.collectionId}/reviews?rules=not-default`) diff --git a/test/api/mocha/data/review/reviewPost.test.js b/test/api/mocha/data/review/reviewPost.test.js index 03b6501f..3858ff97 100644 --- a/test/api/mocha/data/review/reviewPost.test.js +++ b/test/api/mocha/data/review/reviewPost.test.js @@ -1115,7 +1115,8 @@ describe('POST - Review', () => { let deletedCollection, deletedAsset before(async function () { this.timeout(4000) - await utils.putReviewByAssetRule(reference.testCollection.collectionId, reference.testAsset.assetId, reference.testCollection.ruleId, requestBodies.requestBodies) + //await utils.putReviewByAssetRule(reference.testCollection.collectionId, reference.testAsset.assetId, reference.testCollection.ruleId, requestBodies.requestBodies) + await utils.deleteReviewsByAssetRule(reference.testCollection.collectionId, reference.testAsset.assetId, reference.testCollection.ruleId) const deletedItems = await utils.createDisabledCollectionsandAssets() deletedCollection = deletedItems.collection deletedAsset = deletedItems.asset @@ -1127,7 +1128,7 @@ describe('POST - Review', () => { .set('Authorization', `Bearer ${iteration.token}`) .send([ { - "ruleId": `SV-106191r1_rule`, + "ruleId": reference.testCollection.ruleId, "result": "pass", "detail": "test\nvisible to lvl1", "comment": "sure", diff --git a/test/api/mocha/data/user/requestBodies.js b/test/api/mocha/data/user/requestBodies.js index 7f3567fc..4d0906cf 100644 --- a/test/api/mocha/data/user/requestBodies.js +++ b/test/api/mocha/data/user/requestBodies.js @@ -2,7 +2,7 @@ const reference = require('../../referenceData.js') const requestBodies = { scrapUser: { - "username": "TEST_USER", + "username": "additionalTemp", "collectionGrants": [ { "collectionId": reference.scrapCollection.collectionId, diff --git a/test/api/mocha/data/user/user.test.js b/test/api/mocha/data/user/user.test.js index 74c82170..ea7cb1f3 100644 --- a/test/api/mocha/data/user/user.test.js +++ b/test/api/mocha/data/user/user.test.js @@ -12,19 +12,27 @@ let testUser = null const randomValue = Math.floor(Math.random() * 10000) describe('user', () => { - + + before(async function () { + await utils.loadAppData() + }) + for(const iteration of iterations) { describe(`iteration:${iteration.name}`, () => { - describe('GET - user', () => { + before(async function () { + await utils.loadAppData() + // this is here because after we do the gets we need to create a temp user to do all posts, patches, and puts etc on. + // as a result we will have an extra user in the gets to consider + const create = JSON.parse(JSON.stringify(requestBodies.scrapUser)) + create.username = create.username + Math.floor(Math.random() * 1000) + Date.now() + testUser = await utils.createUser(create) + }) - before(async function () { - this.timeout(4000) - await utils.loadAppData() - }) + describe('GET - user', () => { - describe(`GET - getUserObject - /user`, () => { + describe(`getUserObject - /user`, () => { it('Return the requesters user information - check user', async () => { const res = await chai @@ -41,7 +49,7 @@ describe('user', () => { }) }) - describe(`GET - getUsers - /user`, () => { + describe(`getUsers - /user`, () => { it('Return a list of users accessible to the requester USERNAME', async () => { @@ -159,13 +167,15 @@ describe('user', () => { } expect(res).to.have.status(200) expect(res.body).to.be.an('array') - expect(res.body, "expect to get back all usersIds with elevate").to.be.an('array').of.length(reference.allUserIds.length) + // plus one for test user created in before + expect(res.body, "expect to get back all usersIds with elevate").to.be.an('array').of.length(reference.allUserIds.length + 1) for(let user of res.body) { expect(user).to.have.property('collectionGrants') expect(user).to.have.property('statistics') expect(user).to.have.property('username') expect(user).to.have.property('userId') - expect(user.userId, "expect userId to be one of the users the system").to.be.oneOf(reference.allUserIds) + const newIds = reference.allUserIds.concat(testUser.userId) + expect(user.userId, "expect userId to be one of the users the system").to.be.oneOf(newIds) } }) it('Return a list of users accessible to the requester no projections for lvl1 success. ', async () => { @@ -176,9 +186,12 @@ describe('user', () => { .set('Authorization', 'Bearer ' + iteration.token) expect(res).to.have.status(200) - expect(res.body).to.be.an('array').of.length(reference.allUserIds.length) + // plus one for test user created in before + expect(res.body).to.be.an('array').of.length(reference.allUserIds.length + 1) for(let user of res.body) { - expect(user.userId, "expect userId to be one of the users the system").to.be.oneOf(reference.allUserIds) + // plus one for test user created in before + const newIds = reference.allUserIds.concat(testUser.userId) + expect(user.userId, "expect userId to be one of the users the system").to.be.oneOf(newIds) } }) it("should throw SmError.PrivilegeError no elevate with projections.", async () => { @@ -191,7 +204,7 @@ describe('user', () => { }) }) - describe(`GET - getUserByUserId - /users{userId}`, async () => { + describe(`getUserByUserId - /users{userId}`, async () => { it('Return a user', async () => { const res = await chai @@ -215,14 +228,14 @@ describe('user', () => { describe('POST - user', () => { describe(`POST - createUser - /users`, () => { - // let newUser = null + let tempUser = null it('Create a user', async () => { const res = await chai .request(config.baseUrl) .post(`/users?elevate=true&projection=collectionGrants&projection=statistics`) .set('Authorization', 'Bearer ' + iteration.token) .send({ - "username": "TEST_USER" + randomValue, + "username": "TEMP_USER" + randomValue, "collectionGrants": [ { "collectionId": `${reference.scrapCollection.collectionId}`, @@ -234,7 +247,7 @@ describe('user', () => { expect(res).to.have.status(403) return } - testUser = res.body + tempUser = res.body expect(res).to.have.status(201) expect(res.body).to.be.an('object') for(let grant of res.body.collectionGrants) { @@ -277,7 +290,7 @@ describe('user', () => { .post(`/users?elevate=true`) .set('Authorization', 'Bearer ' + iteration.token) .send({ - "username": `${testUser.username}`, + "username": `${tempUser.username}`, "collectionGrants": [ { "collectionId": `${reference.scrapCollection.collectionId}`, @@ -292,19 +305,19 @@ describe('user', () => { expect(res).to.have.status(422) }) } - // if(iteration.name == "stigmanadmin"){ - // it('cleanup - delete test user', async () => { - // const res = await chai - // .request(config.baseUrl) - // .delete(`/users/${newUser.userId}?elevate=true`) - // .set('Authorization', 'Bearer ' + iteration.token) - // if(iteration.name != "stigmanadmin"){ - // expect(res).to.have.status(403) - // return - // } - // expect(res).to.have.status(200) - // }) - // } + if(iteration.name == "stigmanadmin"){ + it('cleanup - delete temp user', async () => { + const res = await chai + .request(config.baseUrl) + .delete(`/users/${tempUser.userId}?elevate=true`) + .set('Authorization', 'Bearer ' + iteration.token) + if(iteration.name != "stigmanadmin"){ + expect(res).to.have.status(403) + return + } + expect(res).to.have.status(200) + }) + } }) }) @@ -428,7 +441,6 @@ describe('user', () => { expect(res).to.have.status(422) }) }) - }) describe('DELETE - user', () => { diff --git a/test/api/mocha/utils/testUtils.js b/test/api/mocha/utils/testUtils.js index 456bdb94..7cf5c781 100644 --- a/test/api/mocha/utils/testUtils.js +++ b/test/api/mocha/utils/testUtils.js @@ -56,7 +56,7 @@ const createTempCollection = async (collectionPost) => { if (!collectionPost) { collectionPost = { - name: 'temoCollection', + name: 'temoCollection' + Math.floor(Math.random() * 1000) + Date.now(), description: 'Collection TEST description', settings: { fields: { @@ -585,6 +585,24 @@ const putReviewByAssetRule = async (collectionId, assetId, ruleId, body) => { } } +const deleteReviewsByAssetRule = async (collectionId, assetId, ruleId) => { + + try{ + const res = await axios.delete( + `${config.baseUrl}/collections/${collectionId}/reviews/${assetId}/${ruleId}`, + { + headers: { + Authorization: `Bearer ${adminToken}`, + 'Content-Type': 'application/json' + } + } + ) + } + catch (e) { + return e; + } +} + const resetTestAsset = async () => { const res = await putAsset("42", { name: "Collection_X_lvl1_asset-1", @@ -669,7 +687,7 @@ const createUser = async (user) => { } const putAsset = async (assetId, asset) => { try { - const res = await axios.patch( + const res = await axios.put( `${config.baseUrl}/assets/${assetId}`, asset, { @@ -686,9 +704,50 @@ const putAsset = async (assetId, asset) => { } } +const putCollection = async (collectionId, collection) => { + try { + const res = await axios.put( + `${config.baseUrl}/collections/${collectionId}`, + collection, + { + headers: { + Authorization: `Bearer ${adminToken}`, + 'Content-Type': 'application/json' + } + } + ) + return res.data + } + catch (e) { + return e; + } +} + +const createCollectionLabel = async (collectionId, label) => { + try { + const res = await axios.post( + `${config.baseUrl}/collections/${collectionId}/labels`, + label, + { + headers: { + Authorization: `Bearer ${adminToken}`, + 'Content-Type': 'application/json' + } + } + ) + return res.data + } + catch (e) { + return e; + } +} + module.exports = { + createCollectionLabel, + putCollection, putReviewByAssetRule, createUser, + deleteReviewsByAssetRule, resetTestAsset, resetScrapAsset, setRestrictedUsers,