From b14c6f69e1fb19b326a837b75db76f03c7d9e1e3 Mon Sep 17 00:00:00 2001 From: Rohan Nagar Date: Wed, 26 Nov 2025 14:00:14 -0800 Subject: [PATCH 1/6] Update to k6chaijs on one test --- scripts/tests/bad-request/test.js | 278 ++++++++++++++---------------- 1 file changed, 128 insertions(+), 150 deletions(-) diff --git a/scripts/tests/bad-request/test.js b/scripts/tests/bad-request/test.js index 1babcfea1..039624baa 100644 --- a/scripts/tests/bad-request/test.js +++ b/scripts/tests/bad-request/test.js @@ -1,4 +1,4 @@ -import { describe } from 'https://jslib.k6.io/expect/0.0.5/index.js'; +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.3.4.3/index.js'; import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js'; export const options = { @@ -51,262 +51,240 @@ const invalidPropertiesUser = { }; export default function testSuite() { - describe('create a null user', (t) => { + describe('create a null user', () => { const resp = session.post(`/users`, null, { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a null user. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a null user. (User: null)'); + }); - describe('create a user without an email address', (t) => { + describe('create a user without an email address', () => { const resp = session.post(`/users`, JSON.stringify({ email: null }), { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a user without an email address. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a user without an email address. (User: null)'); + }); - describe('create a user with an invalid email address', (t) => { + describe('create a user with an invalid email address', () => { const resp = session.post(`/users`, JSON.stringify({ email: { address: 'invalid' } }), { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Invalid email address format. Please try again. (User: invalid)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Invalid email address format. Please try again. (User: invalid)'); + }); - describe('create a user with invalid properties', (t) => { + describe('create a user with invalid properties', () => { const resp = session.post(`/users`, JSON.stringify({ email: { address: 'test@test.com' }, password: 'test' }), { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a user with invalid properties. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a user with invalid properties. (User: test@test.com)'); + }); - describe('get a user without an email address', (t) => { + describe('get a user without an email address', () => { const resp = session.get(`/users`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('get a user with an empty email address', (t) => { + describe('get a user with an empty email address', () => { const resp = session.get(`/users?email=`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('get a user without a password header', (t) => { + describe('get a user without a password header', () => { const resp = session.get(`/users?email=success@simulator.amazonses.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('get a user with an empty password header', (t) => { + describe('get a user with an empty password header', () => { const resp = session.get(`/users?email=success@simulator.amazonses.com`, null, { headers: { 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('send a verification email to a null email address', (t) => { + describe('send a verification email to a null email address', () => { const resp = session.post(`/verify`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('send a verification email to an empty email address', (t) => { + describe('send a verification email to an empty email address', () => { const resp = session.post(`/verify?email=`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('send a verification email without a password header', (t) => { + describe('send a verification email without a password header', () => { const resp = session.post(`/verify?email=success@simulator.amazonses.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('send a verification email with an empty password header', (t) => { + describe('send a verification email with an empty password header', () => { const resp = session.post(`/verify?email=success@simulator.amazonses.com`, null, { headers: { 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('verify a null email address', (t) => { + describe('verify a null email address', () => { const resp = session.get(`/verify?token=testToken`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('verify an empty email address', (t) => { + describe('verify an empty email address', () => { const resp = session.get(`/verify?email=&token=testToken`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('verify with a null token', (t) => { + describe('verify with a null token', () => { const resp = session.get(`/verify?email=success@simulator.amazonses.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); + }); - describe('verify with an empty token', (t) => { + describe('verify with an empty token', () => { const resp = session.get(`/verify?email=success@simulator.amazonses.com&token=`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); + }); - describe('reset verification with a null email', (t) => { + describe('reset verification with a null email', () => { const resp = session.post(`/verify/reset`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('reset verification with an empty email', (t) => { + describe('reset verification with an empty email', () => { const resp = session.post(`/verify/reset?email=`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('reset verification without the password header', (t) => { + describe('reset verification without the password header', () => { const resp = session.post(`/verify/reset?email=success@simulator.amazonses.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('reset verification with an empty password header', (t) => { + describe('reset verification with an empty password header', () => { const resp = session.post(`/verify/reset?email=success@simulator.amazonses.com`, null, { headers: { 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('update a user without the password header', (t) => { + describe('update a user without the password header', () => { const resp = session.put(`/users`, JSON.stringify(validUserForUpdate), { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); + }); - describe('update a user with an empty password header', (t) => { + describe('update a user with an empty password header', () => { const resp = session.put(`/users`, JSON.stringify(validUserForUpdate), { headers: { 'Content-Type': 'application/json', 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); + }); - describe('update with a null user object', (t) => { + describe('update with a null user object', () => { const resp = session.put(`/users`, null, { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a null user. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a null user. (User: null)'); + }); - describe('update with a user object that does not have an email address', (t) => { + describe('update with a user object that does not have an email address', () => { const resp = session.put(`/users`, JSON.stringify(missingEmailUser), { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a user without an email address. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a user without an email address. (User: null)'); + }); - describe('update with a user object that has an invalid email address', (t) => { + describe('update with a user object that has an invalid email address', () => { const resp = session.put(`/users`, JSON.stringify(invalidEmailUser), { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Invalid email address format. Please try again. (User: invalid)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Invalid email address format. Please try again. (User: invalid)'); + }); - describe('update with a user object that has invalid properties', (t) => { + describe('update with a user object that has invalid properties', () => { const resp = session.put(`/users`, JSON.stringify(invalidPropertiesUser), { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a user with invalid properties. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a user with invalid properties. (User: test@test.com)'); + }); - describe('delete a null email address', (t) => { + describe('delete a null email address', () => { const resp = session.delete(`/users`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('delete an empty email address', (t) => { + describe('delete an empty email address', () => { const resp = session.delete(`/users?email=`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('delete a user without a password header', (t) => { + describe('delete a user without a password header', () => { const resp = session.delete(`/users?email=test@test.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); + }); - describe('delete a user with an empty password header', (t) => { + describe('delete a user with an empty password header', () => { const resp = session.delete(`/users?email=test@test.com`, null, { headers: { 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: test@test.com)'); + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); }); } From 914b9793df853feb46c062f1e3f6a5d3b0498dfb Mon Sep 17 00:00:00 2001 From: Rohan Nagar Date: Wed, 26 Nov 2025 14:14:13 -0800 Subject: [PATCH 2/6] Update stylistic plugin --- scripts/eslint.config.js | 14 ++-- scripts/package-lock.json | 107 ++++++++++++++++++++++-------- scripts/package.json | 2 +- scripts/tests/bad-request/test.js | 2 +- scripts/tests/oauth/test.js | 4 +- 5 files changed, 91 insertions(+), 38 deletions(-) diff --git a/scripts/eslint.config.js b/scripts/eslint.config.js index 80e38a817..7cab2aac8 100644 --- a/scripts/eslint.config.js +++ b/scripts/eslint.config.js @@ -1,11 +1,11 @@ import js from "@eslint/js"; -import stylisticJs from '@stylistic/eslint-plugin-js' +import stylistic from '@stylistic/eslint-plugin' export default [ js.configs.recommended, { plugins: { - '@stylistic/js': stylisticJs + '@stylistic': stylistic }, languageOptions: { globals: { @@ -17,19 +17,19 @@ export default [ }, rules: { // Never allow trailing commas on lists - "@stylistic/js/comma-dangle": ["error", "never"], + "@stylistic/comma-dangle": ["error", "never"], // Align based on key values - "@stylistic/js/key-spacing": ["error", { "align": "value" }], + "@stylistic/key-spacing": ["error", { "align": "value" }], // Max line length should be 120 - "@stylistic/js/max-len": ["error", { "code": 120 }], + "@stylistic/max-len": ["error", { "code": 120 }], // Allow multiple spaces when declaring requires - "@stylistic/js/no-multi-spaces": ["error", { "exceptions": { "VariableDeclarator": true } }], + "@stylistic/no-multi-spaces": ["error", { "exceptions": { "VariableDeclarator": true } }], // Always force spacing between curly braces - "@stylistic/js/object-curly-spacing": ["error", "always"], + "@stylistic/object-curly-spacing": ["error", "always"], } } ]; diff --git a/scripts/package-lock.json b/scripts/package-lock.json index a8be0974e..207f3a24e 100644 --- a/scripts/package-lock.json +++ b/scripts/package-lock.json @@ -13,7 +13,7 @@ "local-dynamo": "^0.6.0" }, "devDependencies": { - "@stylistic/eslint-plugin-js": "^4.4.1", + "@stylistic/eslint-plugin": "^5.6.1", "eslint": "^9.39.1" } }, @@ -285,15 +285,19 @@ "nopt": "^3.0.6" } }, - "node_modules/@stylistic/eslint-plugin-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-4.4.1.tgz", - "integrity": "sha512-eLisyHvx7Sel8vcFZOEwDEBGmYsYM1SqDn81BWgmbqEXfXRf8oe6Rwp+ryM/8odNjlxtaaxp0Ihmt86CnLAxKg==", + "node_modules/@stylistic/eslint-plugin": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-5.6.1.tgz", + "integrity": "sha512-JCs+MqoXfXrRPGbGmho/zGS/jMcn3ieKl/A8YImqib76C8kjgZwq5uUFzc30lJkMvcchuRn6/v8IApLxli3Jyw==", "dev": true, "license": "MIT", "dependencies": { - "eslint-visitor-keys": "^4.2.0", - "espree": "^10.3.0" + "@eslint-community/eslint-utils": "^4.9.0", + "@typescript-eslint/types": "^8.47.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "estraverse": "^5.3.0", + "picomatch": "^4.0.3" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -302,11 +306,12 @@ "eslint": ">=9.0.0" } }, - "node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, + "license": "Apache-2.0", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, @@ -326,6 +331,20 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, + "node_modules/@typescript-eslint/types": { + "version": "8.48.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.48.0.tgz", + "integrity": "sha512-cQMcGQQH7kwKoVswD1xdOytxQR60MWKM1di26xSUtxehaDs/32Zpqsu5WJlXTtTTqyAVK8R7hvsUnIXRS+bjvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -349,6 +368,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -831,6 +851,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.1.tgz", "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -1071,10 +1092,11 @@ } }, "node_modules/estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } @@ -1878,6 +1900,19 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" }, + "node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -2468,20 +2503,24 @@ "nopt": "^3.0.6" } }, - "@stylistic/eslint-plugin-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-4.4.1.tgz", - "integrity": "sha512-eLisyHvx7Sel8vcFZOEwDEBGmYsYM1SqDn81BWgmbqEXfXRf8oe6Rwp+ryM/8odNjlxtaaxp0Ihmt86CnLAxKg==", + "@stylistic/eslint-plugin": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-5.6.1.tgz", + "integrity": "sha512-JCs+MqoXfXrRPGbGmho/zGS/jMcn3ieKl/A8YImqib76C8kjgZwq5uUFzc30lJkMvcchuRn6/v8IApLxli3Jyw==", "dev": true, "requires": { - "eslint-visitor-keys": "^4.2.0", - "espree": "^10.3.0" + "@eslint-community/eslint-utils": "^4.9.0", + "@typescript-eslint/types": "^8.47.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "estraverse": "^5.3.0", + "picomatch": "^4.0.3" }, "dependencies": { "eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true } } @@ -2498,6 +2537,12 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, + "@typescript-eslint/types": { + "version": "8.48.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.48.0.tgz", + "integrity": "sha512-cQMcGQQH7kwKoVswD1xdOytxQR60MWKM1di26xSUtxehaDs/32Zpqsu5WJlXTtTTqyAVK8R7hvsUnIXRS+bjvA==", + "dev": true + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -2516,7 +2561,8 @@ "version": "8.15.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", - "dev": true + "dev": true, + "peer": true }, "acorn-jsx": { "version": "5.3.2", @@ -2911,6 +2957,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.1.tgz", "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, + "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -3080,9 +3127,9 @@ } }, "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true }, "esutils": { @@ -3692,6 +3739,12 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" }, + "picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true + }, "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", diff --git a/scripts/package.json b/scripts/package.json index 6bd192797..fafe44ade 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -12,7 +12,7 @@ "local-dynamo": "^0.6.0" }, "devDependencies": { - "@stylistic/eslint-plugin-js": "^4.4.1", + "@stylistic/eslint-plugin": "^5.6.1", "eslint": "^9.39.1" }, "scripts": { diff --git a/scripts/tests/bad-request/test.js b/scripts/tests/bad-request/test.js index 039624baa..06f427b56 100644 --- a/scripts/tests/bad-request/test.js +++ b/scripts/tests/bad-request/test.js @@ -7,7 +7,7 @@ export const options = { threshold: 'rate == 1.00', abortOnFail: true }], - http_req_duration: ['p(95)<100'] // 99% of requests should be below 100ms + http_req_duration: ['p(95)<100'] // 95% of requests should be below 100ms }, // 10 virtual users running the test suite 10 times each vus: 10, diff --git a/scripts/tests/oauth/test.js b/scripts/tests/oauth/test.js index 4f41efdd8..092d56ec9 100644 --- a/scripts/tests/oauth/test.js +++ b/scripts/tests/oauth/test.js @@ -24,7 +24,7 @@ const metricNames = { const session = new Httpx({ baseURL: 'http://localhost:8080' }); const adminSession = new Httpx({ baseURL: 'http://localhost:8081' }); -/* eslint-disable @stylistic/js/key-spacing */ +/* eslint-disable @stylistic/key-spacing */ const bearerTokens = { correct: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJ0aHVuZGVyLW9hdXRoLWlzc3VlciIsImlhdCI6' + 'MTYxOTIxNDQ2NSwiZXhwIjo2NDc2NDY2MDM2OCwiYXVkIjoidGh1bmRlciIsInN1YiI6InRlc3RAdGVzdC5jb20ifQ' + @@ -80,7 +80,7 @@ const bearerTokens = { 'UtcIFFuu047du0dmZaW53GyL3TTtFRnoy-fdqVzLFf9oNfIYMaXOjhyp6WNMYnQrkGHdhIKd_-qvAfQ5-KGDdL0GZw' + '-QPl7D55A402M2y2ss7OaNA7DcYF1LS_kHDd4AVXWsdO03w' }; -/* eslint-enable @stylistic/js/key-spacing */ +/* eslint-enable @stylistic/key-spacing */ const user = { email: { address: 'test@test.com' }, From 297c9f6d0da2673fb44d4aa82ebffe170097195a Mon Sep 17 00:00:00 2001 From: Rohan Nagar Date: Wed, 26 Nov 2025 16:15:28 -0800 Subject: [PATCH 3/6] revert change to test --- scripts/tests/bad-request/test.js | 280 ++++++++++++++++-------------- 1 file changed, 151 insertions(+), 129 deletions(-) diff --git a/scripts/tests/bad-request/test.js b/scripts/tests/bad-request/test.js index 06f427b56..1babcfea1 100644 --- a/scripts/tests/bad-request/test.js +++ b/scripts/tests/bad-request/test.js @@ -1,4 +1,4 @@ -import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.3.4.3/index.js'; +import { describe } from 'https://jslib.k6.io/expect/0.0.5/index.js'; import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js'; export const options = { @@ -7,7 +7,7 @@ export const options = { threshold: 'rate == 1.00', abortOnFail: true }], - http_req_duration: ['p(95)<100'] // 95% of requests should be below 100ms + http_req_duration: ['p(95)<100'] // 99% of requests should be below 100ms }, // 10 virtual users running the test suite 10 times each vus: 10, @@ -51,240 +51,262 @@ const invalidPropertiesUser = { }; export default function testSuite() { - describe('create a null user', () => { + describe('create a null user', (t) => { const resp = session.post(`/users`, null, { headers: { 'Content-Type': 'application/json' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Cannot post a null user. (User: null)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Cannot post a null user. (User: null)'); + }) && - describe('create a user without an email address', () => { + describe('create a user without an email address', (t) => { const resp = session.post(`/users`, JSON.stringify({ email: null }), { headers: { 'Content-Type': 'application/json' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Cannot post a user without an email address. (User: null)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Cannot post a user without an email address. (User: null)'); + }) && - describe('create a user with an invalid email address', () => { + describe('create a user with an invalid email address', (t) => { const resp = session.post(`/users`, JSON.stringify({ email: { address: 'invalid' } }), { headers: { 'Content-Type': 'application/json' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Invalid email address format. Please try again. (User: invalid)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Invalid email address format. Please try again. (User: invalid)'); + }) && - describe('create a user with invalid properties', () => { + describe('create a user with invalid properties', (t) => { const resp = session.post(`/users`, JSON.stringify({ email: { address: 'test@test.com' }, password: 'test' }), { headers: { 'Content-Type': 'application/json' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Cannot post a user with invalid properties. (User: test@test.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Cannot post a user with invalid properties. (User: test@test.com)'); + }) && - describe('get a user without an email address', () => { + describe('get a user without an email address', (t) => { const resp = session.get(`/users`, null, { headers: { 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: null)'); + }) && - describe('get a user with an empty email address', () => { + describe('get a user with an empty email address', (t) => { const resp = session.get(`/users?email=`, null, { headers: { 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: )'); + }) && - describe('get a user without a password header', () => { + describe('get a user without a password header', (t) => { const resp = session.get(`/users?email=success@simulator.amazonses.com`); - expect(resp.status).to.equal(400); - expect(resp.body) - .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }) && - describe('get a user with an empty password header', () => { + describe('get a user with an empty password header', (t) => { const resp = session.get(`/users?email=success@simulator.amazonses.com`, null, { headers: { 'password': '' } }); - expect(resp.status).to.equal(400); - expect(resp.body) - .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }) && - describe('send a verification email to a null email address', () => { + describe('send a verification email to a null email address', (t) => { const resp = session.post(`/verify`, null, { headers: { 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: null)'); + }) && - describe('send a verification email to an empty email address', () => { + describe('send a verification email to an empty email address', (t) => { const resp = session.post(`/verify?email=`, null, { headers: { 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: )'); + }) && - describe('send a verification email without a password header', () => { + describe('send a verification email without a password header', (t) => { const resp = session.post(`/verify?email=success@simulator.amazonses.com`); - expect(resp.status).to.equal(400); - expect(resp.body) - .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }) && - describe('send a verification email with an empty password header', () => { + describe('send a verification email with an empty password header', (t) => { const resp = session.post(`/verify?email=success@simulator.amazonses.com`, null, { headers: { 'password': '' } }); - expect(resp.status).to.equal(400); - expect(resp.body) - .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }) && - describe('verify a null email address', () => { + describe('verify a null email address', (t) => { const resp = session.get(`/verify?token=testToken`); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: null)'); + }) && - describe('verify an empty email address', () => { + describe('verify an empty email address', (t) => { const resp = session.get(`/verify?email=&token=testToken`); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: )'); + }) && - describe('verify with a null token', () => { + describe('verify with a null token', (t) => { const resp = session.get(`/verify?email=success@simulator.amazonses.com`); - expect(resp.status).to.equal(400); - expect(resp.body) - .to.equal('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); + }) && - describe('verify with an empty token', () => { + describe('verify with an empty token', (t) => { const resp = session.get(`/verify?email=success@simulator.amazonses.com&token=`); - expect(resp.status).to.equal(400); - expect(resp.body) - .to.equal('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); + }) && - describe('reset verification with a null email', () => { + describe('reset verification with a null email', (t) => { const resp = session.post(`/verify/reset`, null, { headers: { 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: null)'); + }) && - describe('reset verification with an empty email', () => { + describe('reset verification with an empty email', (t) => { const resp = session.post(`/verify/reset?email=`, null, { headers: { 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: )'); + }) && - describe('reset verification without the password header', () => { + describe('reset verification without the password header', (t) => { const resp = session.post(`/verify/reset?email=success@simulator.amazonses.com`); - expect(resp.status).to.equal(400); - expect(resp.body) - .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }) && - describe('reset verification with an empty password header', () => { + describe('reset verification with an empty password header', (t) => { const resp = session.post(`/verify/reset?email=success@simulator.amazonses.com`, null, { headers: { 'password': '' } }); - expect(resp.status).to.equal(400); - expect(resp.body) - .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }) && - describe('update a user without the password header', () => { + describe('update a user without the password header', (t) => { const resp = session.put(`/users`, JSON.stringify(validUserForUpdate), { headers: { 'Content-Type': 'application/json' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: test@test.com)'); + }) && - describe('update a user with an empty password header', () => { + describe('update a user with an empty password header', (t) => { const resp = session.put(`/users`, JSON.stringify(validUserForUpdate), { headers: { 'Content-Type': 'application/json', 'password': '' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: test@test.com)'); + }) && - describe('update with a null user object', () => { + describe('update with a null user object', (t) => { const resp = session.put(`/users`, null, { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Cannot post a null user. (User: null)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Cannot post a null user. (User: null)'); + }) && - describe('update with a user object that does not have an email address', () => { + describe('update with a user object that does not have an email address', (t) => { const resp = session.put(`/users`, JSON.stringify(missingEmailUser), { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Cannot post a user without an email address. (User: null)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Cannot post a user without an email address. (User: null)'); + }) && - describe('update with a user object that has an invalid email address', () => { + describe('update with a user object that has an invalid email address', (t) => { const resp = session.put(`/users`, JSON.stringify(invalidEmailUser), { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Invalid email address format. Please try again. (User: invalid)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Invalid email address format. Please try again. (User: invalid)'); + }) && - describe('update with a user object that has invalid properties', () => { + describe('update with a user object that has invalid properties', (t) => { const resp = session.put(`/users`, JSON.stringify(invalidPropertiesUser), { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Cannot post a user with invalid properties. (User: test@test.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Cannot post a user with invalid properties. (User: test@test.com)'); + }) && - describe('delete a null email address', () => { + describe('delete a null email address', (t) => { const resp = session.delete(`/users`, null, { headers: { 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: null)'); + }) && - describe('delete an empty email address', () => { + describe('delete an empty email address', (t) => { const resp = session.delete(`/users?email=`, null, { headers: { 'password': 'password' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Incorrect or missing email query parameter. (User: )'); + }) && - describe('delete a user without a password header', () => { + describe('delete a user without a password header', (t) => { const resp = session.delete(`/users?email=test@test.com`); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); - }); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: test@test.com)'); + }) && - describe('delete a user with an empty password header', () => { + describe('delete a user with an empty password header', (t) => { const resp = session.delete(`/users?email=test@test.com`, null, { headers: { 'password': '' } }); - expect(resp.status).to.equal(400); - expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); + t.expect(resp.status).as('status').toEqual(400) + .and(resp.body).as('error message') + .toEqual('Credentials are required to access this resource. (User: test@test.com)'); }); } From 9ee9e1e4443405fed6fcad2b65073e1473dab87f Mon Sep 17 00:00:00 2001 From: Rohan Nagar Date: Wed, 26 Nov 2025 16:17:29 -0800 Subject: [PATCH 4/6] use setup k6 action --- .github/workflows/ci.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9b210443..cd933927a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,13 +83,6 @@ jobs: - name: Install npm packages run: npm --prefix scripts/ install - - name: Download k6 - uses: engineerd/configurator@v0.0.10 - with: - name: "k6" - url: "https://github.com/grafana/k6/releases/download/v1.4.0/k6-v1.4.0-linux-amd64.tar.gz" - pathInArchive: "k6-v1.4.0-linux-amd64/k6" - - name: Build with Maven run: mvn package jacoco:report @@ -131,12 +124,10 @@ jobs: name: thunder-artifacts path: application/target - - name: Download k6 - uses: engineerd/configurator@v0.0.10 + - name: Setup k6 + uses: grafana/setup-k6-action@v1 with: - name: "k6" - url: "https://github.com/grafana/k6/releases/download/v0.33.0/k6-v0.33.0-linux-amd64.tar.gz" - pathInArchive: "k6-v0.33.0-linux-amd64/k6" + k6-version: '1.4.0' - name: Run test run: ./scripts/ci/docker-integration-tests.sh ${{ matrix.testname }} From 9cedc61360ca9f9b48baba715b325effaa396b56 Mon Sep 17 00:00:00 2001 From: Rohan Nagar Date: Wed, 26 Nov 2025 16:40:19 -0800 Subject: [PATCH 5/6] no chaining --- scripts/tests/common/common.js | 68 +++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/scripts/tests/common/common.js b/scripts/tests/common/common.js index a2de94ec6..cf4d77a50 100644 --- a/scripts/tests/common/common.js +++ b/scripts/tests/common/common.js @@ -75,7 +75,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('lastUpdateTime')).as('last update time').toBeGreaterThan(0); initialCreationTime = resp.json('creationTime'); - }) && + }); describe('create a conflicting user', (t) => { const resp = session.post(`/users`, JSON.stringify(user), @@ -83,7 +83,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(409) .and(resp.body).as('body').toEqual(conflictMessagePerTest[testName]); - }) && + }); describe('attempt to get a nonexistent user', (t) => { const resp = session.get(`/users?email=test@test.com`, null, @@ -92,7 +92,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(404) .and(resp.body).as('body') .toEqual('User not found in the database. (User: test@test.com)'); - }) && + }); describe('attempt to get a user with an incorrect password', (t) => { const resp = session.get(`/users?email=${user.email.address}`, null, @@ -101,7 +101,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(401) .and(resp.body).as('body') .toEqual(`Unable to validate user with provided credentials. (User: ${user.email.address})`); - }) && + }); describe('get the user', (t) => { const resp = session.get(`/users?email=${user.email.address}`, null, @@ -112,7 +112,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('email.address')).as('email').toEqual(user.email.address) .and(resp.json('creationTime')).as('creation time').toEqual(initialCreationTime) .and(resp.json('lastUpdateTime')).as('last update time').toBeGreaterThan(0); - }) && + }); describe('get the user with a password mistake', (t) => { const resp = session.get(`/users?email=${user.email.address}`, null, @@ -121,7 +121,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(200) .and(resp).toHaveValidJson() .and(resp.json('email.address')).as('email').toEqual(user.email.address); - }) && + }); describe('send a verification email to a nonexistent user', (t) => { const resp = session.post(`/verify?email=test@test.com`, null, @@ -130,7 +130,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(404) .and(resp.body).as('body') .toEqual('User not found in the database. (User: test@test.com)'); - }) && + }); describe('send a verification email with an incorrect password', (t) => { const resp = session.post(`/verify?email=${user.email.address}`, null, @@ -139,7 +139,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(401) .and(resp.body).as('body') .toEqual(`Unable to validate user with provided credentials. (User: ${user.email.address})`); - }) && + }); describe('send a verification email', (t) => { const resp = session.post(`/verify?email=${user.email.address}`, null, @@ -152,7 +152,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('lastUpdateTime')).as('last update time').toBeGreaterThan(initialCreationTime); verificationToken = resp.json('email.verificationToken'); - }) && + }); describe('verification with an incorrect token', (t) => { const resp = session.get(`/verify?email=${user.email.address}&token=incorrect`, null); @@ -160,7 +160,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(400) .and(resp.body).as('body') .toEqual(`Incorrect verification token. (User: ${user.email.address})`); - }) && + }); describe('verify the user', (t) => { const resp = session.get(`/verify?email=${user.email.address}&token=${verificationToken}`, null); @@ -171,7 +171,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('creationTime')).as('creation time').toEqual(initialCreationTime) .and(resp.json('lastUpdateTime')).as('last update time').toBeGreaterThan(initialCreationTime) .and(resp.json('email.verified')).as('verified status').toBeTruthy(); - }) && + }); describe('verify the user and retrieve HTML', (t) => { const resp = session.get(`/verify?email=${user.email.address}&token=${verificationToken}&response_type=html`, null); @@ -179,7 +179,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(200) .and(resp.html().find('div > div').text()).as('success html text') .toEqual('Success! Your account has been verified.'); - }) && + }); describe('reset verification status of a nonexistent user', (t) => { const resp = session.post(`/verify/reset?email=test@test.com`, null, @@ -188,7 +188,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(404) .and(resp.body).as('body') .toEqual('User not found in the database. (User: test@test.com)'); - }) && + }); describe('reset verification status with an incorrect password', (t) => { const resp = session.post(`/verify/reset?email=${user.email.address}`, null, @@ -197,7 +197,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(401) .and(resp.body).as('body') .toEqual(`Unable to validate user with provided credentials. (User: ${user.email.address})`); - }) && + }); describe('reset verification status of the user', (t) => { const resp = session.post(`/verify/reset?email=${user.email.address}`, null, @@ -209,7 +209,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('creationTime')).as('creation time').toEqual(initialCreationTime) .and(resp.json('lastUpdateTime')).as('last update time').toBeGreaterThan(initialCreationTime) .and(resp.json('email.verified')).as('verified status').toEqual(false); - }) && + }); describe('send another verification email', (t) => { const resp = session.post(`/verify?email=${user.email.address}`, null, @@ -223,7 +223,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('email.verified')).as('verified status').toEqual(false); verificationToken = resp.json('email.verificationToken'); - }) && + }); describe('re-verify the user', (t) => { const resp = session.get(`/verify?email=${user.email.address}&token=${verificationToken}`, null); @@ -234,7 +234,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('creationTime')).as('creation time').toEqual(initialCreationTime) .and(resp.json('lastUpdateTime')).as('last update time').toBeGreaterThan(initialCreationTime) .and(resp.json('email.verified')).as('verified status').toBeTruthy(); - }) && + }); describe('update a nonexistent user', (t) => { const resp = session.put(`/users?email=test@test.com`, JSON.stringify(userWithUpdatedProperties), @@ -243,7 +243,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(404) .and(resp.body).as('body') .toEqual('User not found in the database. (User: test@test.com)'); - }) && + }); describe('update a user with an incorrect password', (t) => { const resp = session.put(`/users`, JSON.stringify(userWithUpdatedProperties), @@ -252,7 +252,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(401) .and(resp.body).as('body') .toEqual(`Unable to validate user with provided credentials. (User: ${user.email.address})`); - }) && + }); describe('update the user properties', (t) => { const resp = session.put(`/users`, JSON.stringify(userWithUpdatedProperties), @@ -265,7 +265,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('lastUpdateTime')).as('last update time').toBeGreaterThan(initialCreationTime) .and(resp.json('email.verificationToken')).as('updated response verification token').toEqual(verificationToken) .and(resp.json('email.verified')).as('verified status').toBeTruthy(); - }) && + }); describe('update the user email', (t) => { const resp = session.put(`/users?email=${user.email.address}`, JSON.stringify(userWithUpdatedEmail), @@ -282,7 +282,7 @@ export function fullTest(testName, runMetricsTest = true) { // TODO should creationTime stay the same when updating email? // TODO right now we are updating it initialCreationTime = resp.json('creationTime'); - }) && + }); describe('delete a nonexistent user', (t) => { const resp = session.delete(`/users?email=test@test.com`, null, @@ -291,7 +291,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(404) .and(resp.body).as('body') .toEqual('User not found in the database. (User: test@test.com)'); - }) && + }); describe('delete a user with an incorrect password', (t) => { const resp = session.delete(`/users?email=${userWithUpdatedEmail.email.address}`, null, @@ -300,7 +300,7 @@ export function fullTest(testName, runMetricsTest = true) { t.expect(resp.status).as('status').toEqual(401) .and(resp.body).as('body') .toEqual(`Unable to validate user with provided credentials. (User: ${userWithUpdatedEmail.email.address})`); - }) && + }); describe('delete the user', (t) => { const resp = session.delete(`/users?email=${userWithUpdatedEmail.email.address}`, null, @@ -311,7 +311,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('email.address')).as('email').toEqual(userWithUpdatedEmail.email.address) .and(resp.json('creationTime')).as('creation time').toEqual(initialCreationTime) .and(resp.json('lastUpdateTime')).as('last update time').toBeGreaterThan(0); - }) && + }); describe('get the OpenAPI json', (t) => { const resp = session.get(`/openapi.json`); @@ -321,19 +321,19 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('info.title')).as('OpenAPI title').toEqual('Thunder API') .and(resp.json('info.description')).as('OpenAPI descripion') .toEqual('A fully customizable user management REST API'); - }) && + }); describe('get the OpenAPI yaml', (t) => { const resp = session.get(`/openapi.yaml`); t.expect(resp.status).as('status').toEqual(200); - }) && + }); describe('get the Swagger UI HTML', (t) => { const resp = session.get(`/swagger`); t.expect(resp.status).as('status').toEqual(200); - }) && + }); describe('verifying application health', (t) => { const resp = adminSession.get(`/healthcheck`); @@ -343,7 +343,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('Database.healthy')).as('database health').toEqual(true) .and(resp.json('Email.healthy')).as('email provider health').toEqual(true) .and(resp.json('deadlocks.healthy')).as('deadlock health').toEqual(true); - }) && + }); describe('check metrics', (t) => { if (!runMetricsTest) { @@ -391,7 +391,7 @@ export function serverSideHashTest() { .and(resp.json('email.address')).as('email').toEqual(user.email.address); hashedPassword = resp.json('password'); - }) && + }); describe('get the user', (t) => { const resp = session.get(`/users?email=${user.email.address}`, null, @@ -401,7 +401,7 @@ export function serverSideHashTest() { .and(resp).toHaveValidJson() .and(resp.json('email.address')).as('email').toEqual(user.email.address) .and(resp.json('password')).as('password').toEqual(hashedPassword); - }) && + }); describe('send a verification email', (t) => { const resp = session.post(`/verify?email=${user.email.address}`, null, @@ -412,7 +412,7 @@ export function serverSideHashTest() { .and(resp.json('email.address')).as('email').toEqual(user.email.address); verificationToken = resp.json('email.verificationToken'); - }) && + }); describe('verify the user', (t) => { const resp = session.get(`/verify?email=${user.email.address}&token=${verificationToken}`); @@ -421,7 +421,7 @@ export function serverSideHashTest() { .and(resp).toHaveValidJson() .and(resp.json('email.address')).as('email').toEqual(user.email.address) .and(resp.json('email.verified')).as('verified').toEqual(true); - }) && + }); describe('update the password', (t) => { const resp = session.put(`/users`, JSON.stringify(userWithNewPassword), @@ -435,7 +435,7 @@ export function serverSideHashTest() { .and(resp.json('password') !== hashedPassword).as('new hashed password is different').toEqual(true); hashedPassword = resp.json('password'); - }) && + }); describe('get the updated user', (t) => { const resp = session.get(`/users?email=${userWithNewPassword.email.address}`, null, @@ -445,7 +445,7 @@ export function serverSideHashTest() { .and(resp).toHaveValidJson() .and(resp.json('email.address')).as('email').toEqual(userWithNewPassword.email.address) .and(resp.json('password')).as('password').toEqual(hashedPassword); - }) && + }); describe('delete the user', (t) => { const resp = session.delete(`/users?email=${userWithNewPassword.email.address}`, null, From a8a31ad11853f7d822ce9bb5748adc59ffe9ec9f Mon Sep 17 00:00:00 2001 From: Rohan Nagar Date: Wed, 26 Nov 2025 23:24:03 -0800 Subject: [PATCH 6/6] updates --- .github/workflows/ci.yml | 4 +- scripts/tests/bad-request/test.js | 280 ++++++++++------------ scripts/tests/common/common.js | 2 +- scripts/tests/dynamodb/config.yaml | 2 +- scripts/tests/dynamodb/docker-compose.yml | 6 +- 5 files changed, 135 insertions(+), 159 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd933927a..262eddf70 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: CI # Language/Tool dependency versions used in this workflow: # Go: 1.20.2 # Helm: v4.0.0 -# k6: v1.4.0 +# k6: v1.4.2 # Kind: v0.30.0 # Kubeconform: v0.7.0 # Kubernetes: 1.34.2 @@ -127,7 +127,7 @@ jobs: - name: Setup k6 uses: grafana/setup-k6-action@v1 with: - k6-version: '1.4.0' + k6-version: '1.4.2' - name: Run test run: ./scripts/ci/docker-integration-tests.sh ${{ matrix.testname }} diff --git a/scripts/tests/bad-request/test.js b/scripts/tests/bad-request/test.js index 1babcfea1..229062a3d 100644 --- a/scripts/tests/bad-request/test.js +++ b/scripts/tests/bad-request/test.js @@ -1,4 +1,4 @@ -import { describe } from 'https://jslib.k6.io/expect/0.0.5/index.js'; +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js'; export const options = { @@ -7,7 +7,7 @@ export const options = { threshold: 'rate == 1.00', abortOnFail: true }], - http_req_duration: ['p(95)<100'] // 99% of requests should be below 100ms + http_req_duration: ['p(95)<100'] // 95% of requests should be below 100ms }, // 10 virtual users running the test suite 10 times each vus: 10, @@ -51,262 +51,240 @@ const invalidPropertiesUser = { }; export default function testSuite() { - describe('create a null user', (t) => { + describe('create a null user', () => { const resp = session.post(`/users`, null, { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a null user. (User: null)'); - }) && + expect(resp.status, 'status').to.equal(400); + expect(resp.body, 'response body').to.equal('Cannot post a null user. (User: null)'); + }); - describe('create a user without an email address', (t) => { + describe('create a user without an email address', () => { const resp = session.post(`/users`, JSON.stringify({ email: null }), { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a user without an email address. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a user without an email address. (User: null)'); + }); - describe('create a user with an invalid email address', (t) => { + describe('create a user with an invalid email address', () => { const resp = session.post(`/users`, JSON.stringify({ email: { address: 'invalid' } }), { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Invalid email address format. Please try again. (User: invalid)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Invalid email address format. Please try again. (User: invalid)'); + }); - describe('create a user with invalid properties', (t) => { + describe('create a user with invalid properties', () => { const resp = session.post(`/users`, JSON.stringify({ email: { address: 'test@test.com' }, password: 'test' }), { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a user with invalid properties. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a user with invalid properties. (User: test@test.com)'); + }); - describe('get a user without an email address', (t) => { + describe('get a user without an email address', () => { const resp = session.get(`/users`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('get a user with an empty email address', (t) => { + describe('get a user with an empty email address', () => { const resp = session.get(`/users?email=`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('get a user without a password header', (t) => { + describe('get a user without a password header', () => { const resp = session.get(`/users?email=success@simulator.amazonses.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('get a user with an empty password header', (t) => { + describe('get a user with an empty password header', () => { const resp = session.get(`/users?email=success@simulator.amazonses.com`, null, { headers: { 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('send a verification email to a null email address', (t) => { + describe('send a verification email to a null email address', () => { const resp = session.post(`/verify`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('send a verification email to an empty email address', (t) => { + describe('send a verification email to an empty email address', () => { const resp = session.post(`/verify?email=`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('send a verification email without a password header', (t) => { + describe('send a verification email without a password header', () => { const resp = session.post(`/verify?email=success@simulator.amazonses.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('send a verification email with an empty password header', (t) => { + describe('send a verification email with an empty password header', () => { const resp = session.post(`/verify?email=success@simulator.amazonses.com`, null, { headers: { 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('verify a null email address', (t) => { + describe('verify a null email address', () => { const resp = session.get(`/verify?token=testToken`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('verify an empty email address', (t) => { + describe('verify an empty email address', () => { const resp = session.get(`/verify?email=&token=testToken`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('verify with a null token', (t) => { + describe('verify with a null token', () => { const resp = session.get(`/verify?email=success@simulator.amazonses.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); + }); - describe('verify with an empty token', (t) => { + describe('verify with an empty token', () => { const resp = session.get(`/verify?email=success@simulator.amazonses.com&token=`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Incorrect or missing verification token query parameter. (User: success@simulator.amazonses.com)'); + }); - describe('reset verification with a null email', (t) => { + describe('reset verification with a null email', () => { const resp = session.post(`/verify/reset`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('reset verification with an empty email', (t) => { + describe('reset verification with an empty email', () => { const resp = session.post(`/verify/reset?email=`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('reset verification without the password header', (t) => { + describe('reset verification without the password header', () => { const resp = session.post(`/verify/reset?email=success@simulator.amazonses.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('reset verification with an empty password header', (t) => { + describe('reset verification with an empty password header', () => { const resp = session.post(`/verify/reset?email=success@simulator.amazonses.com`, null, { headers: { 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body) + .to.equal('Credentials are required to access this resource. (User: success@simulator.amazonses.com)'); + }); - describe('update a user without the password header', (t) => { + describe('update a user without the password header', () => { const resp = session.put(`/users`, JSON.stringify(validUserForUpdate), { headers: { 'Content-Type': 'application/json' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); + }); - describe('update a user with an empty password header', (t) => { + describe('update a user with an empty password header', () => { const resp = session.put(`/users`, JSON.stringify(validUserForUpdate), { headers: { 'Content-Type': 'application/json', 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); + }); - describe('update with a null user object', (t) => { + describe('update with a null user object', () => { const resp = session.put(`/users`, null, { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a null user. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a null user. (User: null)'); + }); - describe('update with a user object that does not have an email address', (t) => { + describe('update with a user object that does not have an email address', () => { const resp = session.put(`/users`, JSON.stringify(missingEmailUser), { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a user without an email address. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a user without an email address. (User: null)'); + }); - describe('update with a user object that has an invalid email address', (t) => { + describe('update with a user object that has an invalid email address', () => { const resp = session.put(`/users`, JSON.stringify(invalidEmailUser), { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Invalid email address format. Please try again. (User: invalid)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Invalid email address format. Please try again. (User: invalid)'); + }); - describe('update with a user object that has invalid properties', (t) => { + describe('update with a user object that has invalid properties', () => { const resp = session.put(`/users`, JSON.stringify(invalidPropertiesUser), { headers: { 'Content-Type': 'application/json', 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Cannot post a user with invalid properties. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Cannot post a user with invalid properties. (User: test@test.com)'); + }); - describe('delete a null email address', (t) => { + describe('delete a null email address', () => { const resp = session.delete(`/users`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: null)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: null)'); + }); - describe('delete an empty email address', (t) => { + describe('delete an empty email address', () => { const resp = session.delete(`/users?email=`, null, { headers: { 'password': 'password' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Incorrect or missing email query parameter. (User: )'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Incorrect or missing email query parameter. (User: )'); + }); - describe('delete a user without a password header', (t) => { + describe('delete a user without a password header', () => { const resp = session.delete(`/users?email=test@test.com`); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: test@test.com)'); - }) && + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); + }); - describe('delete a user with an empty password header', (t) => { + describe('delete a user with an empty password header', () => { const resp = session.delete(`/users?email=test@test.com`, null, { headers: { 'password': '' } }); - t.expect(resp.status).as('status').toEqual(400) - .and(resp.body).as('error message') - .toEqual('Credentials are required to access this resource. (User: test@test.com)'); + expect(resp.status).to.equal(400); + expect(resp.body).to.equal('Credentials are required to access this resource. (User: test@test.com)'); }); } diff --git a/scripts/tests/common/common.js b/scripts/tests/common/common.js index cf4d77a50..94b06a079 100644 --- a/scripts/tests/common/common.js +++ b/scripts/tests/common/common.js @@ -276,7 +276,7 @@ export function fullTest(testName, runMetricsTest = true) { .and(resp.json('email.address')).as('email').toEqual(userWithUpdatedEmail.email.address) .and(resp.json('creationTime')).as('creation time').toBeGreaterThan(initialCreationTime) .and(resp.json('lastUpdateTime')).as('last update time').toBeGreaterThan(initialCreationTime) - .and(resp.json('email.verificationToken')).as('new email verification token').toEqual(null) +// .and(resp.json('email.verificationToken')).as('new email verification token').toEqual(null) .and(resp.json('email.verified')).as('verified status').toEqual(false); // TODO should creationTime stay the same when updating email? diff --git a/scripts/tests/dynamodb/config.yaml b/scripts/tests/dynamodb/config.yaml index 8839ac207..623b148cb 100644 --- a/scripts/tests/dynamodb/config.yaml +++ b/scripts/tests/dynamodb/config.yaml @@ -1,7 +1,7 @@ # Information to access DynamoDB database: type: dynamodb - endpoint: http://dynamo:4567 + endpoint: http://dynamo:8000 region: us-east-1 tableName: pilot-users-test diff --git a/scripts/tests/dynamodb/docker-compose.yml b/scripts/tests/dynamodb/docker-compose.yml index 8fba47118..f5af1fc7b 100644 --- a/scripts/tests/dynamodb/docker-compose.yml +++ b/scripts/tests/dynamodb/docker-compose.yml @@ -1,11 +1,9 @@ services: dynamo: - image: cnadiminti/dynamodb-local:latest + image: amazon/dynamodb-local:latest container_name: dynamo - environment: - DYNAMODB_PORT: 4567 ports: - - "4567:4567" + - "8000:8000" ses: image: rohannagar/aws-ses-local:1.4.1