-
Notifications
You must be signed in to change notification settings - Fork 0
feat: use ssl config for mysql connections, update build process DMD-1605 #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| lib | ||
| node_modules | ||
| coverage | ||
| .idea | ||
| .idea | ||
| .yarn |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| nodeLinker: node-modules |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,9 +26,23 @@ describe('serverless mysql utility', () => { | |||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||
| await executeQuery('', dbConfig); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // then | ||||||||||||||||||||||||||||||
| // then - implementation adds ssl: {} when undefined so mysql uses secure connection (required for caching_sha2_password) | ||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledTimes(1); | ||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledWith(dbConfig); | ||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledWith(expect.objectContaining({ ...dbConfig, ssl: {} })); | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| it('should pass through ssl config when provided', async () => { | ||||||||||||||||||||||||||||||
| const dbConfig = { | ||||||||||||||||||||||||||||||
| database: chance.word(), | ||||||||||||||||||||||||||||||
| host: chance.word(), | ||||||||||||||||||||||||||||||
| password: chance.word(), | ||||||||||||||||||||||||||||||
| user: chance.word(), | ||||||||||||||||||||||||||||||
| ssl: { ca: chance.string() }, | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix key order to satisfy The linter expects 🔧 Suggested reorder- user: chance.word(),
- ssl: { ca: chance.string() },
+ ssl: { ca: chance.string() },
+ user: chance.word(),📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 40-40: Expected object keys to be in ascending order. 'ssl' should be before 'user'. (sort-keys) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| await executeQuery('', dbConfig); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledWith(expect.objectContaining({ ssl: dbConfig.ssl })); | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| it('should successfully query mysql on the first try', async () => { | ||||||||||||||||||||||||||||||
|
|
@@ -84,9 +98,9 @@ describe('serverless mysql utility', () => { | |||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||
| await executeQueryWithParams('', [], dbConfig); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // then | ||||||||||||||||||||||||||||||
| // then - implementation adds ssl: {} when undefined so mysql uses secure connection (required for caching_sha2_password) | ||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledTimes(1); | ||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledWith(dbConfig); | ||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledWith(expect.objectContaining({ ...dbConfig, ssl: {} })); | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| it('should successfully query mysql on the first try', async () => { | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,9 +34,23 @@ describe('execute Transaction', () => { | |||||||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||||||
| await executeTransaction(queries, dbConfig); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // then | ||||||||||||||||||||||||||||||||||
| // then - implementation adds ssl: {} when undefined so mysql uses secure connection (required for caching_sha2_password) | ||||||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledTimes(1); | ||||||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledWith(dbConfig); | ||||||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledWith({ ...dbConfig, ssl: {} }); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| it('should pass through ssl config when provided', async () => { | ||||||||||||||||||||||||||||||||||
| const dbConfig = { | ||||||||||||||||||||||||||||||||||
| database: chance.word(), | ||||||||||||||||||||||||||||||||||
| host: chance.word(), | ||||||||||||||||||||||||||||||||||
| password: chance.word(), | ||||||||||||||||||||||||||||||||||
| user: chance.word(), | ||||||||||||||||||||||||||||||||||
| ssl: { ca: chance.string() }, | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix key order to satisfy ESLint’s sort-keys rule expects 🔧 Suggested reorder- user: chance.word(),
- ssl: { ca: chance.string() },
+ ssl: { ca: chance.string() },
+ user: chance.word(),📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 48-48: Expected object keys to be in ascending order. 'ssl' should be before 'user'. (sort-keys) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| await executeTransaction([], dbConfig); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| expect(getPool).toHaveBeenCalledWith(expect.objectContaining({ ssl: dbConfig.ssl })); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| it('should successfully query mysql on the first try', async () => { | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ async function wrap<T extends RowData[] | QueryInfo>( | |
| host: dbConfig.host, | ||
| password: dbConfig.password, | ||
| user: dbConfig.user, | ||
| ssl: dbConfig.ssl !== undefined ? dbConfig.ssl : {}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's find test files and check getPool mocks
rg -n -A 10 'getPool' --glob '*spec*' --glob '*test*'Repository: TractorZoom/serverless-mysql-utils Length of output: 8850 🏁 Script executed: # Also check the execute-query.ts file to see how getPool is used
cat -n src/execute-query.ts | head -40Repository: TractorZoom/serverless-mysql-utils Length of output: 1504 🏁 Script executed: # Find all test files to understand the structure
fd -e spec.ts -e test.tsRepository: TractorZoom/serverless-mysql-utils Length of output: 108 🏁 Script executed: # Let's see the full execute-query.spec.js file, especially the beforeEach and how mockPool is configured
cat -n __tests__/execute-query.spec.js | head -70Repository: TractorZoom/serverless-mysql-utils Length of output: 2933 🏁 Script executed: # Also check if there are methods added to mockPool later in the file
cat -n __tests__/execute-query.spec.js | sed -n '48,90p'Repository: TractorZoom/serverless-mysql-utils Length of output: 1855 🏁 Script executed: # Let's check the executeQueryWithParams test section to see if execute method is mocked
cat -n __tests__/execute-query.spec.js | sed -n '88,150p'Repository: TractorZoom/serverless-mysql-utils Length of output: 2769 🏁 Script executed: # Also look for any setup or teardown that might be relevant
cat -n __tests__/execute-query.spec.js | tail -100Repository: TractorZoom/serverless-mysql-utils Length of output: 4297 Add pool method mocks to the test beforeEach setup. The test file initializes beforeEach(() => {
mockPool = {
query: jest.fn().mockResolvedValue([[], null]),
execute: jest.fn().mockResolvedValue([[], null]),
};
getPool.mockResolvedValue(mockPool);
});This ensures all tests have functional pool methods available, and individual tests can override them as needed. 🧰 Tools🪛 ESLint[error] 18-18: Expected object keys to be in ascending order. 'ssl' should be before 'user'. (sort-keys) 🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| let data: T; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix job dependency:
build-and-publishdoesn’t exist.This will fail the workflow;
npm-publishshould depend onbuild-and-test.✅ Suggested fix
📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.10)
[error] 21-21: job "npm-publish" needs job "build-and-publish" which does not exist in this workflow
(job-needs)
🤖 Prompt for AI Agents