disable secrets integ tests temp

This commit is contained in:
Maidul Islam
2023-04-28 13:17:46 -04:00
parent 3471e387ae
commit db0f0d0d9c

View File

@@ -1,408 +1,408 @@
import request from 'supertest' // import request from 'supertest'
import main from '../../../../src/index' // import main from '../../../../src/index'
import { testWorkspaceId } from '../../../../src/utils/addDevelopmentUser'; // import { testWorkspaceId } from '../../../../src/utils/addDevelopmentUser';
import { deleteAllSecrets, getAllSecrets, getJWTFromTestUser, getServiceTokenFromTestUser } from '../../../helper/helper'; // import { deleteAllSecrets, getAllSecrets, getJWTFromTestUser, getServiceTokenFromTestUser } from '../../../helper/helper';
// eslint-disable-next-line @typescript-eslint/no-var-requires // // eslint-disable-next-line @typescript-eslint/no-var-requires
const batchSecretRequestWithNoOverride = require('../../../data/batch-secrets-no-override.json'); // const batchSecretRequestWithNoOverride = require('../../../data/batch-secrets-no-override.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires // // eslint-disable-next-line @typescript-eslint/no-var-requires
const batchSecretRequestWithOverrides = require('../../../data/batch-secrets-with-overrides.json'); // const batchSecretRequestWithOverrides = require('../../../data/batch-secrets-with-overrides.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires // // eslint-disable-next-line @typescript-eslint/no-var-requires
const batchSecretRequestWithBadRequest = require('../../../data/batch-create-secrets-with-some-missing-params.json'); // const batchSecretRequestWithBadRequest = require('../../../data/batch-create-secrets-with-some-missing-params.json');
let server: any; // let server: any;
beforeAll(async () => { // beforeAll(async () => {
server = await main; // server = await main;
}); // });
afterAll(async () => { // afterAll(async () => {
server.close(); // server.close();
}); // });
describe("GET /api/v2/secrets", () => { // describe("GET /api/v2/secrets", () => {
describe("Get secrets via JTW", () => { // describe("Get secrets via JTW", () => {
test("should create secrets and read secrets via jwt", async () => { // test("should create secrets and read secrets via jwt", async () => {
try { // try {
// get login details // // get login details
const loginResponse = await getJWTFromTestUser() // const loginResponse = await getJWTFromTestUser()
// create creates // // create creates
const createSecretsResponse = await request(server) // const createSecretsResponse = await request(server)
.post("/api/v2/secrets/batch") // .post("/api/v2/secrets/batch")
.set('Authorization', `Bearer ${loginResponse.token}`) // .set('Authorization', `Bearer ${loginResponse.token}`)
.send({ // .send({
workspaceId: testWorkspaceId, // workspaceId: testWorkspaceId,
environment: "dev", // environment: "dev",
requests: batchSecretRequestWithNoOverride // requests: batchSecretRequestWithNoOverride
}) // })
expect(createSecretsResponse.statusCode).toBe(200) // expect(createSecretsResponse.statusCode).toBe(200)
const getSecrets = await request(server) // const getSecrets = await request(server)
.get("/api/v2/secrets") // .get("/api/v2/secrets")
.set('Authorization', `Bearer ${loginResponse.token}`) // .set('Authorization', `Bearer ${loginResponse.token}`)
.query({ // .query({
workspaceId: testWorkspaceId, // workspaceId: testWorkspaceId,
environment: "dev" // environment: "dev"
}) // })
expect(getSecrets.statusCode).toBe(200) // expect(getSecrets.statusCode).toBe(200)
expect(getSecrets.body).toHaveProperty("secrets") // expect(getSecrets.body).toHaveProperty("secrets")
expect(getSecrets.body.secrets).toHaveLength(3) // expect(getSecrets.body.secrets).toHaveLength(3)
expect(getSecrets.body.secrets).toBeInstanceOf(Array); // expect(getSecrets.body.secrets).toBeInstanceOf(Array);
getSecrets.body.secrets.forEach((secret: any) => { // getSecrets.body.secrets.forEach((secret: any) => {
expect(secret).toHaveProperty('_id'); // expect(secret).toHaveProperty('_id');
expect(secret._id).toBeTruthy(); // expect(secret._id).toBeTruthy();
expect(secret).toHaveProperty('version'); // expect(secret).toHaveProperty('version');
expect(secret.version).toBeTruthy(); // expect(secret.version).toBeTruthy();
expect(secret).toHaveProperty('workspace'); // expect(secret).toHaveProperty('workspace');
expect(secret.workspace).toBeTruthy(); // expect(secret.workspace).toBeTruthy();
expect(secret).toHaveProperty('type'); // expect(secret).toHaveProperty('type');
expect(secret.type).toBeTruthy(); // expect(secret.type).toBeTruthy();
expect(secret).toHaveProperty('tags'); // expect(secret).toHaveProperty('tags');
expect(secret.tags).toHaveLength(0); // expect(secret.tags).toHaveLength(0);
expect(secret).toHaveProperty('environment'); // expect(secret).toHaveProperty('environment');
expect(secret.environment).toEqual("dev"); // expect(secret.environment).toEqual("dev");
expect(secret).toHaveProperty('secretKeyCiphertext'); // expect(secret).toHaveProperty('secretKeyCiphertext');
expect(secret.secretKeyCiphertext).toBeTruthy(); // expect(secret.secretKeyCiphertext).toBeTruthy();
expect(secret).toHaveProperty('secretKeyIV'); // expect(secret).toHaveProperty('secretKeyIV');
expect(secret.secretKeyIV).toBeTruthy(); // expect(secret.secretKeyIV).toBeTruthy();
expect(secret).toHaveProperty('secretKeyTag'); // expect(secret).toHaveProperty('secretKeyTag');
expect(secret.secretKeyTag).toBeTruthy(); // expect(secret.secretKeyTag).toBeTruthy();
expect(secret).toHaveProperty('secretValueCiphertext'); // expect(secret).toHaveProperty('secretValueCiphertext');
expect(secret.secretValueCiphertext).toBeTruthy(); // expect(secret.secretValueCiphertext).toBeTruthy();
expect(secret).toHaveProperty('secretValueIV'); // expect(secret).toHaveProperty('secretValueIV');
expect(secret.secretValueIV).toBeTruthy(); // expect(secret.secretValueIV).toBeTruthy();
expect(secret).toHaveProperty('secretValueTag'); // expect(secret).toHaveProperty('secretValueTag');
expect(secret.secretValueTag).toBeTruthy(); // expect(secret.secretValueTag).toBeTruthy();
expect(secret).toHaveProperty('secretCommentCiphertext'); // expect(secret).toHaveProperty('secretCommentCiphertext');
expect(secret.secretCommentCiphertext).toBeFalsy(); // expect(secret.secretCommentCiphertext).toBeFalsy();
expect(secret).toHaveProperty('secretCommentIV'); // expect(secret).toHaveProperty('secretCommentIV');
expect(secret.secretCommentIV).toBeTruthy(); // expect(secret.secretCommentIV).toBeTruthy();
expect(secret).toHaveProperty('secretCommentTag'); // expect(secret).toHaveProperty('secretCommentTag');
expect(secret.secretCommentTag).toBeTruthy(); // expect(secret.secretCommentTag).toBeTruthy();
expect(secret).toHaveProperty('createdAt'); // expect(secret).toHaveProperty('createdAt');
expect(secret.createdAt).toBeTruthy(); // expect(secret.createdAt).toBeTruthy();
expect(secret).toHaveProperty('updatedAt'); // expect(secret).toHaveProperty('updatedAt');
expect(secret.updatedAt).toBeTruthy(); // expect(secret.updatedAt).toBeTruthy();
}); // });
} finally { // } finally {
// clean up // // clean up
await deleteAllSecrets() // await deleteAllSecrets()
} // }
}) // })
test("Get secrets via jwt when personal overrides exist", async () => { // test("Get secrets via jwt when personal overrides exist", async () => {
try { // try {
// get login details // // get login details
const loginResponse = await getJWTFromTestUser() // const loginResponse = await getJWTFromTestUser()
// create creates // // create creates
const createSecretsResponse = await request(server) // const createSecretsResponse = await request(server)
.post("/api/v2/secrets/batch") // .post("/api/v2/secrets/batch")
.set('Authorization', `Bearer ${loginResponse.token}`) // .set('Authorization', `Bearer ${loginResponse.token}`)
.send({ // .send({
workspaceId: testWorkspaceId, // workspaceId: testWorkspaceId,
environment: "dev", // environment: "dev",
requests: batchSecretRequestWithOverrides // requests: batchSecretRequestWithOverrides
}) // })
expect(createSecretsResponse.statusCode).toBe(200) // expect(createSecretsResponse.statusCode).toBe(200)
const getSecrets = await request(server) // const getSecrets = await request(server)
.get("/api/v2/secrets") // .get("/api/v2/secrets")
.set('Authorization', `Bearer ${loginResponse.token}`) // .set('Authorization', `Bearer ${loginResponse.token}`)
.query({ // .query({
workspaceId: testWorkspaceId, // workspaceId: testWorkspaceId,
environment: "dev" // environment: "dev"
}) // })
expect(getSecrets.statusCode).toBe(200) // expect(getSecrets.statusCode).toBe(200)
expect(getSecrets.body).toHaveProperty("secrets") // expect(getSecrets.body).toHaveProperty("secrets")
expect(getSecrets.body.secrets).toHaveLength(2) // expect(getSecrets.body.secrets).toHaveLength(2)
expect(getSecrets.body.secrets).toBeInstanceOf(Array); // expect(getSecrets.body.secrets).toBeInstanceOf(Array);
getSecrets.body.secrets.forEach((secret: any) => { // getSecrets.body.secrets.forEach((secret: any) => {
expect(secret).toHaveProperty('_id'); // expect(secret).toHaveProperty('_id');
expect(secret._id).toBeTruthy(); // expect(secret._id).toBeTruthy();
expect(secret).toHaveProperty('version'); // expect(secret).toHaveProperty('version');
expect(secret.version).toBeTruthy(); // expect(secret.version).toBeTruthy();
expect(secret).toHaveProperty('workspace'); // expect(secret).toHaveProperty('workspace');
expect(secret.workspace).toBeTruthy(); // expect(secret.workspace).toBeTruthy();
expect(secret).toHaveProperty('type'); // expect(secret).toHaveProperty('type');
expect(secret.type).toBeTruthy(); // expect(secret.type).toBeTruthy();
expect(secret).toHaveProperty('tags'); // expect(secret).toHaveProperty('tags');
expect(secret.tags).toHaveLength(0); // expect(secret.tags).toHaveLength(0);
expect(secret).toHaveProperty('environment'); // expect(secret).toHaveProperty('environment');
expect(secret.environment).toEqual("dev"); // expect(secret.environment).toEqual("dev");
expect(secret).toHaveProperty('secretKeyCiphertext'); // expect(secret).toHaveProperty('secretKeyCiphertext');
expect(secret.secretKeyCiphertext).toBeTruthy(); // expect(secret.secretKeyCiphertext).toBeTruthy();
expect(secret).toHaveProperty('secretKeyIV'); // expect(secret).toHaveProperty('secretKeyIV');
expect(secret.secretKeyIV).toBeTruthy(); // expect(secret.secretKeyIV).toBeTruthy();
expect(secret).toHaveProperty('secretKeyTag'); // expect(secret).toHaveProperty('secretKeyTag');
expect(secret.secretKeyTag).toBeTruthy(); // expect(secret.secretKeyTag).toBeTruthy();
expect(secret).toHaveProperty('secretValueCiphertext'); // expect(secret).toHaveProperty('secretValueCiphertext');
expect(secret.secretValueCiphertext).toBeTruthy(); // expect(secret.secretValueCiphertext).toBeTruthy();
expect(secret).toHaveProperty('secretValueIV'); // expect(secret).toHaveProperty('secretValueIV');
expect(secret.secretValueIV).toBeTruthy(); // expect(secret.secretValueIV).toBeTruthy();
expect(secret).toHaveProperty('secretValueTag'); // expect(secret).toHaveProperty('secretValueTag');
expect(secret.secretValueTag).toBeTruthy(); // expect(secret.secretValueTag).toBeTruthy();
expect(secret).toHaveProperty('secretCommentCiphertext'); // expect(secret).toHaveProperty('secretCommentCiphertext');
expect(secret.secretCommentCiphertext).toBeFalsy(); // expect(secret.secretCommentCiphertext).toBeFalsy();
expect(secret).toHaveProperty('secretCommentIV'); // expect(secret).toHaveProperty('secretCommentIV');
expect(secret.secretCommentIV).toBeTruthy(); // expect(secret.secretCommentIV).toBeTruthy();
expect(secret).toHaveProperty('secretCommentTag'); // expect(secret).toHaveProperty('secretCommentTag');
expect(secret.secretCommentTag).toBeTruthy(); // expect(secret.secretCommentTag).toBeTruthy();
expect(secret).toHaveProperty('createdAt'); // expect(secret).toHaveProperty('createdAt');
expect(secret.createdAt).toBeTruthy(); // expect(secret.createdAt).toBeTruthy();
expect(secret).toHaveProperty('updatedAt'); // expect(secret).toHaveProperty('updatedAt');
expect(secret.updatedAt).toBeTruthy(); // expect(secret.updatedAt).toBeTruthy();
}); // });
} finally { // } finally {
// clean up // // clean up
await deleteAllSecrets() // await deleteAllSecrets()
} // }
}) // })
}) // })
describe("fetch secrets via service token", () => { // describe("fetch secrets via service token", () => {
test("Get secrets via jwt when personal overrides exist", async () => { // test("Get secrets via jwt when personal overrides exist", async () => {
try { // try {
// get login details // // get login details
const loginResponse = await getJWTFromTestUser() // const loginResponse = await getJWTFromTestUser()
// create creates // // create creates
const createSecretsResponse = await request(server) // const createSecretsResponse = await request(server)
.post("/api/v2/secrets/batch") // .post("/api/v2/secrets/batch")
.set('Authorization', `Bearer ${loginResponse.token}`) // .set('Authorization', `Bearer ${loginResponse.token}`)
.send({ // .send({
workspaceId: testWorkspaceId, // workspaceId: testWorkspaceId,
environment: "dev", // environment: "dev",
requests: batchSecretRequestWithOverrides // requests: batchSecretRequestWithOverrides
}) // })
expect(createSecretsResponse.statusCode).toBe(200) // expect(createSecretsResponse.statusCode).toBe(200)
// now use the service token to fetch secrets // // now use the service token to fetch secrets
const serviceToken = await getServiceTokenFromTestUser() // const serviceToken = await getServiceTokenFromTestUser()
const getSecrets = await request(server) // const getSecrets = await request(server)
.get("/api/v2/secrets") // .get("/api/v2/secrets")
.set('Authorization', `Bearer ${serviceToken}`) // .set('Authorization', `Bearer ${serviceToken}`)
.query({ // .query({
workspaceId: testWorkspaceId, // workspaceId: testWorkspaceId,
environment: "dev" // environment: "dev"
}) // })
expect(getSecrets.statusCode).toBe(200) // expect(getSecrets.statusCode).toBe(200)
expect(getSecrets.body).toHaveProperty("secrets") // expect(getSecrets.body).toHaveProperty("secrets")
expect(getSecrets.body.secrets).toHaveLength(2) // expect(getSecrets.body.secrets).toHaveLength(2)
expect(getSecrets.body.secrets).toBeInstanceOf(Array); // expect(getSecrets.body.secrets).toBeInstanceOf(Array);
getSecrets.body.secrets.forEach((secret: any) => { // getSecrets.body.secrets.forEach((secret: any) => {
expect(secret).toHaveProperty('_id'); // expect(secret).toHaveProperty('_id');
expect(secret._id).toBeTruthy(); // expect(secret._id).toBeTruthy();
expect(secret).toHaveProperty('version'); // expect(secret).toHaveProperty('version');
expect(secret.version).toBeTruthy(); // expect(secret.version).toBeTruthy();
expect(secret).toHaveProperty('workspace'); // expect(secret).toHaveProperty('workspace');
expect(secret.workspace).toBeTruthy(); // expect(secret.workspace).toBeTruthy();
expect(secret).toHaveProperty('type'); // expect(secret).toHaveProperty('type');
expect(secret.type).toBeTruthy(); // expect(secret.type).toBeTruthy();
expect(secret).toHaveProperty('tags'); // expect(secret).toHaveProperty('tags');
expect(secret.tags).toHaveLength(0); // expect(secret.tags).toHaveLength(0);
expect(secret).toHaveProperty('environment'); // expect(secret).toHaveProperty('environment');
expect(secret.environment).toEqual("dev"); // expect(secret.environment).toEqual("dev");
expect(secret).toHaveProperty('secretKeyCiphertext'); // expect(secret).toHaveProperty('secretKeyCiphertext');
expect(secret.secretKeyCiphertext).toBeTruthy(); // expect(secret.secretKeyCiphertext).toBeTruthy();
expect(secret).toHaveProperty('secretKeyIV'); // expect(secret).toHaveProperty('secretKeyIV');
expect(secret.secretKeyIV).toBeTruthy(); // expect(secret.secretKeyIV).toBeTruthy();
expect(secret).toHaveProperty('secretKeyTag'); // expect(secret).toHaveProperty('secretKeyTag');
expect(secret.secretKeyTag).toBeTruthy(); // expect(secret.secretKeyTag).toBeTruthy();
expect(secret).toHaveProperty('secretValueCiphertext'); // expect(secret).toHaveProperty('secretValueCiphertext');
expect(secret.secretValueCiphertext).toBeTruthy(); // expect(secret.secretValueCiphertext).toBeTruthy();
expect(secret).toHaveProperty('secretValueIV'); // expect(secret).toHaveProperty('secretValueIV');
expect(secret.secretValueIV).toBeTruthy(); // expect(secret.secretValueIV).toBeTruthy();
expect(secret).toHaveProperty('secretValueTag'); // expect(secret).toHaveProperty('secretValueTag');
expect(secret.secretValueTag).toBeTruthy(); // expect(secret.secretValueTag).toBeTruthy();
expect(secret).toHaveProperty('secretCommentCiphertext'); // expect(secret).toHaveProperty('secretCommentCiphertext');
expect(secret.secretCommentCiphertext).toBeFalsy(); // expect(secret.secretCommentCiphertext).toBeFalsy();
expect(secret).toHaveProperty('secretCommentIV'); // expect(secret).toHaveProperty('secretCommentIV');
expect(secret.secretCommentIV).toBeTruthy(); // expect(secret.secretCommentIV).toBeTruthy();
expect(secret).toHaveProperty('secretCommentTag'); // expect(secret).toHaveProperty('secretCommentTag');
expect(secret.secretCommentTag).toBeTruthy(); // expect(secret.secretCommentTag).toBeTruthy();
expect(secret).toHaveProperty('createdAt'); // expect(secret).toHaveProperty('createdAt');
expect(secret.createdAt).toBeTruthy(); // expect(secret.createdAt).toBeTruthy();
expect(secret).toHaveProperty('updatedAt'); // expect(secret).toHaveProperty('updatedAt');
expect(secret.updatedAt).toBeTruthy(); // expect(secret.updatedAt).toBeTruthy();
}); // });
} finally { // } finally {
// clean up // // clean up
await deleteAllSecrets() // await deleteAllSecrets()
} // }
}) // })
test("should create secrets and read secrets via service token when no overrides", async () => { // test("should create secrets and read secrets via service token when no overrides", async () => {
try { // try {
// get login details // // get login details
const loginResponse = await getJWTFromTestUser() // const loginResponse = await getJWTFromTestUser()
// create secrets // // create secrets
const createSecretsResponse = await request(server) // const createSecretsResponse = await request(server)
.post("/api/v2/secrets/batch") // .post("/api/v2/secrets/batch")
.set('Authorization', `Bearer ${loginResponse.token}`) // .set('Authorization', `Bearer ${loginResponse.token}`)
.send({ // .send({
workspaceId: testWorkspaceId, // workspaceId: testWorkspaceId,
environment: "dev", // environment: "dev",
requests: batchSecretRequestWithNoOverride // requests: batchSecretRequestWithNoOverride
}) // })
expect(createSecretsResponse.statusCode).toBe(200) // expect(createSecretsResponse.statusCode).toBe(200)
// now use the service token to fetch secrets // // now use the service token to fetch secrets
const serviceToken = await getServiceTokenFromTestUser() // const serviceToken = await getServiceTokenFromTestUser()
const getSecrets = await request(server) // const getSecrets = await request(server)
.get("/api/v2/secrets") // .get("/api/v2/secrets")
.set('Authorization', `Bearer ${serviceToken}`) // .set('Authorization', `Bearer ${serviceToken}`)
.query({ // .query({
workspaceId: testWorkspaceId, // workspaceId: testWorkspaceId,
environment: "dev" // environment: "dev"
}) // })
expect(getSecrets.statusCode).toBe(200) // expect(getSecrets.statusCode).toBe(200)
expect(getSecrets.body).toHaveProperty("secrets") // expect(getSecrets.body).toHaveProperty("secrets")
expect(getSecrets.body.secrets).toHaveLength(3) // expect(getSecrets.body.secrets).toHaveLength(3)
expect(getSecrets.body.secrets).toBeInstanceOf(Array); // expect(getSecrets.body.secrets).toBeInstanceOf(Array);
getSecrets.body.secrets.forEach((secret: any) => { // getSecrets.body.secrets.forEach((secret: any) => {
expect(secret).toHaveProperty('_id'); // expect(secret).toHaveProperty('_id');
expect(secret._id).toBeTruthy(); // expect(secret._id).toBeTruthy();
expect(secret).toHaveProperty('version'); // expect(secret).toHaveProperty('version');
expect(secret.version).toBeTruthy(); // expect(secret.version).toBeTruthy();
expect(secret).toHaveProperty('workspace'); // expect(secret).toHaveProperty('workspace');
expect(secret.workspace).toBeTruthy(); // expect(secret.workspace).toBeTruthy();
expect(secret).toHaveProperty('type'); // expect(secret).toHaveProperty('type');
expect(secret.type).toBeTruthy(); // expect(secret.type).toBeTruthy();
expect(secret).toHaveProperty('tags'); // expect(secret).toHaveProperty('tags');
expect(secret.tags).toHaveLength(0); // expect(secret.tags).toHaveLength(0);
expect(secret).toHaveProperty('environment'); // expect(secret).toHaveProperty('environment');
expect(secret.environment).toEqual("dev"); // expect(secret.environment).toEqual("dev");
expect(secret).toHaveProperty('secretKeyCiphertext'); // expect(secret).toHaveProperty('secretKeyCiphertext');
expect(secret.secretKeyCiphertext).toBeTruthy(); // expect(secret.secretKeyCiphertext).toBeTruthy();
expect(secret).toHaveProperty('secretKeyIV'); // expect(secret).toHaveProperty('secretKeyIV');
expect(secret.secretKeyIV).toBeTruthy(); // expect(secret.secretKeyIV).toBeTruthy();
expect(secret).toHaveProperty('secretKeyTag'); // expect(secret).toHaveProperty('secretKeyTag');
expect(secret.secretKeyTag).toBeTruthy(); // expect(secret.secretKeyTag).toBeTruthy();
expect(secret).toHaveProperty('secretValueCiphertext'); // expect(secret).toHaveProperty('secretValueCiphertext');
expect(secret.secretValueCiphertext).toBeTruthy(); // expect(secret.secretValueCiphertext).toBeTruthy();
expect(secret).toHaveProperty('secretValueIV'); // expect(secret).toHaveProperty('secretValueIV');
expect(secret.secretValueIV).toBeTruthy(); // expect(secret.secretValueIV).toBeTruthy();
expect(secret).toHaveProperty('secretValueTag'); // expect(secret).toHaveProperty('secretValueTag');
expect(secret.secretValueTag).toBeTruthy(); // expect(secret.secretValueTag).toBeTruthy();
expect(secret).toHaveProperty('secretCommentCiphertext'); // expect(secret).toHaveProperty('secretCommentCiphertext');
expect(secret.secretCommentCiphertext).toBeFalsy(); // expect(secret.secretCommentCiphertext).toBeFalsy();
expect(secret).toHaveProperty('secretCommentIV'); // expect(secret).toHaveProperty('secretCommentIV');
expect(secret.secretCommentIV).toBeTruthy(); // expect(secret.secretCommentIV).toBeTruthy();
expect(secret).toHaveProperty('secretCommentTag'); // expect(secret).toHaveProperty('secretCommentTag');
expect(secret.secretCommentTag).toBeTruthy(); // expect(secret.secretCommentTag).toBeTruthy();
expect(secret).toHaveProperty('createdAt'); // expect(secret).toHaveProperty('createdAt');
expect(secret.createdAt).toBeTruthy(); // expect(secret.createdAt).toBeTruthy();
expect(secret).toHaveProperty('updatedAt'); // expect(secret).toHaveProperty('updatedAt');
expect(secret.updatedAt).toBeTruthy(); // expect(secret.updatedAt).toBeTruthy();
}); // });
} finally { // } finally {
// clean up // // clean up
await deleteAllSecrets() // await deleteAllSecrets()
} // }
}) // })
}) // })
describe("create secrets via JWT", () => { // describe("create secrets via JWT", () => {
test("Create secrets via jwt when some requests have missing required parameters", async () => { // test("Create secrets via jwt when some requests have missing required parameters", async () => {
// get login details // // get login details
const loginResponse = await getJWTFromTestUser() // const loginResponse = await getJWTFromTestUser()
// create creates // // create creates
const createSecretsResponse = await request(server) // const createSecretsResponse = await request(server)
.post("/api/v2/secrets/batch") // .post("/api/v2/secrets/batch")
.set('Authorization', `Bearer ${loginResponse.token}`) // .set('Authorization', `Bearer ${loginResponse.token}`)
.send({ // .send({
workspaceId: testWorkspaceId, // workspaceId: testWorkspaceId,
environment: "dev", // environment: "dev",
requests: batchSecretRequestWithBadRequest // requests: batchSecretRequestWithBadRequest
}) // })
const allSecretsInDB = await getAllSecrets() // const allSecretsInDB = await getAllSecrets()
expect(createSecretsResponse.statusCode).toBe(500) // TODO should be set to 400 // expect(createSecretsResponse.statusCode).toBe(500) // TODO should be set to 400
expect(allSecretsInDB).toHaveLength(0) // expect(allSecretsInDB).toHaveLength(0)
}) // })
}) // })
}) // })