Skip to content

Commit

Permalink
add more secret test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
maidul98 committed Feb 19, 2024
1 parent 7070a69 commit 35d589a
Showing 1 changed file with 48 additions and 11 deletions.
59 changes: 48 additions & 11 deletions backend/e2e-test/routes/v1/identity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const deleteRawSecret = async (dto: { path: string; key: string; token: string }
return updatedSecretPayload.secret;
};

describe("Identity token secret ops", async () => {
describe("Secret operations with Identity token", async () => {
let identityToken = "";
let folderId = "";
beforeAll(async () => {
Expand Down Expand Up @@ -183,21 +183,58 @@ describe("Identity token secret ops", async () => {
expect(deleteFolder.statusCode).toBe(200);
});

const testRawSecrets = [
const secretTestCases = [
{
path: "/",
secret: {
key: "ID-SEC",
key: "secret-key-1",
value: "something-secret",
comment: "some comment"
}
},
{
path: "/nested1/nested2/folder",
secret: {
key: "NESTED-ID-SEC",
value: "something-secret",
comment: "some comment"
key: "secret-key-2",
value: `-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCa6eeFk+cMVqFn
hoVQDYgn2Ptp5Azysr2UPq6P73pCL9BzUtOXKZROqDyGehzzfg3wE2KdYU1Jk5Uq
fP0ZOWDIlM2SaVCSI3FW32o5+ZiggjpqcVdLFc/PS0S/ZdSmpPd8h11iO2brtIAI
ugTW8fcKlGSNUwx9aFmE7A6JnTRliTxB1l6QaC+YAwTK39VgeVH2gDSWC407aS15
QobAkaBKKmFkzB5D7i2ZJwt+uXJV/rbLmyDmtnw0lubciGn7NX9wbYef180fisqT
aPNAz0nPKk0fFH2Wd5MZixNGbrrpDA+FCYvI5doThZyT2hpj08qWP07oXXCAqw46
IEupNSILAgMBAAECggEBAIJb5KzeaiZS3B3O8G4OBQ5rJB3WfyLYUHnoSWLsBbie
nc392/ovThLmtZAAQE6SO85Tsb93+t64Z2TKqv1H8G658UeMgfWIB78v4CcLJ2mi
TN/3op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1mo2tr4XDyEeiuK52eTd9
omQDpP86RX/hIIQ+JyLSaWYa
-----END PRIVATE KEY-----`,
comment:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation"
}
},
{
path: "/nested1/nested2/folder",
secret: {
key: "secret-key-3",
value:
"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gU2VkIGRvIGVpdXNtb2QgdGVtcG9yIGluY2lkaWR1bnQgdXQgbGFib3JlIGV0IGRvbG9yZSBtYWduYSBhbGlxdWEuIFV0IGVuaW0gYWQgbWluaW0gdmVuaWFtLCBxdWlzIG5vc3RydWQgZXhlcmNpdGF0aW9uCg==",
comment: ""
}
}
];
Expand All @@ -220,7 +257,7 @@ describe("Identity token secret ops", async () => {
return secrets.map((el) => ({ key: el.secretKey, value: el.secretValue, type: el.type, version: el.version }));
};

test.each(testRawSecrets)("Create secret raw in path $path", async ({ secret, path }) => {
test.each(secretTestCases)("Create raw secret", async ({ secret, path }) => {
const createSecretReqBody = {
workspaceId: seedData1.project.id,
environment: seedData1.environment.slug,
Expand Down Expand Up @@ -256,7 +293,7 @@ describe("Identity token secret ops", async () => {
await deleteRawSecret({ path, key: secret.key, token: identityToken });
});

test.each(testRawSecrets)("Get secret by name raw in path $path", async ({ secret, path }) => {
test.each(secretTestCases)("Fetch raw secret by name", async ({ secret, path }) => {
await createRawSecret({ path, ...secret, token: identityToken });

const getSecByNameRes = await testServer.inject({
Expand Down Expand Up @@ -284,7 +321,7 @@ describe("Identity token secret ops", async () => {
await deleteRawSecret({ path, key: secret.key, token: identityToken });
});

test.each(testRawSecrets)("List secret raw in path $path", async ({ secret, path }) => {
test.each(secretTestCases)("List secret raw in path $path", async ({ secret, path }) => {
await Promise.all(
Array.from(Array(5)).map((_e, i) =>
createRawSecret({ path, token: identityToken, ...secret, key: `BULK-${secret.key}-${i + 1}` })
Expand All @@ -308,7 +345,7 @@ describe("Identity token secret ops", async () => {
);
});

test.each(testRawSecrets)("Update secret raw in path $path", async ({ secret, path }) => {
test.each(secretTestCases)("Update raw secret", async ({ secret, path }) => {
await createRawSecret({ path, ...secret, token: identityToken });

const updateSecretReqBody = {
Expand Down Expand Up @@ -346,7 +383,7 @@ describe("Identity token secret ops", async () => {
await deleteRawSecret({ path, key: secret.key, token: identityToken });
});

test.each(testRawSecrets)("Delete secret raw in path $path", async ({ path, secret }) => {
test.each(secretTestCases)("Delete raw secret", async ({ path, secret }) => {
await createRawSecret({ path, ...secret, token: identityToken });

const deletedSecretReqBody = {
Expand Down

0 comments on commit 35d589a

Please sign in to comment.