-
Notifications
You must be signed in to change notification settings - Fork 0
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
Automatically grant COMS permissions for new users #130
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dc7fb06
Automatically grant COMS permissions for new users
kyle1morel c62fb1c
Resolve unit tests
kyle1morel 3822d86
Update helm docs
kyle1morel c92129e
Update unit tests and helm secrets config
kyle1morel 5bc339e
Resolve rebase conflicts
kyle1morel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ afterEach(() => { | |
jest.resetAllMocks(); | ||
}); | ||
|
||
const CURRENT_CONTEXT = { authType: 'BEARER', tokenPayload: null, userId: 'abc-123' }; | ||
const CURRENT_CONTEXT = { authType: 'BEARER', bearerToken: 'sometoken', tokenPayload: null, userId: 'abc-123' }; | ||
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. Test coverage: Consider testing scenarios where the |
||
|
||
describe('send', () => { | ||
const next = jest.fn(); | ||
|
@@ -188,10 +188,59 @@ describe('send', () => { | |
await roadmapController.send(req as any, res as any, next); | ||
|
||
expect(getObjectsSpy).toHaveBeenCalledTimes(1); | ||
expect(getObjectsSpy).toHaveBeenNthCalledWith(1, req.headers, req.body.selectedFileIds); | ||
expect(getObjectsSpy).toHaveBeenNthCalledWith(1, req.currentContext.bearerToken, req.body.selectedFileIds); | ||
expect(getObjectSpy).toHaveBeenCalledTimes(2); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(1, req.headers, req.body.selectedFileIds[0]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(2, req.headers, req.body.selectedFileIds[1]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(1, req.currentContext.bearerToken, req.body.selectedFileIds[0]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(2, req.currentContext.bearerToken, req.body.selectedFileIds[1]); | ||
expect(emailSpy).toHaveBeenCalledTimes(1); | ||
expect(emailSpy).toHaveBeenCalledWith(req.body.emailData); | ||
expect(res.status).toHaveBeenCalledWith(201); | ||
expect(res.json).toHaveBeenCalledWith(emailResponse.data); | ||
}); | ||
|
||
it('should not call COMS without a bearer token', async () => { | ||
const req = { | ||
body: { | ||
activityId: '123-123', | ||
selectedFileIds: ['123', '456'], | ||
emailData: { | ||
body: 'Some message text', | ||
bodyType: 'text', | ||
from: 'test@gov.bc.ca', | ||
to: 'hello@gov.bc.ca', | ||
subject: 'Unit tests', | ||
attachments: [ | ||
{ | ||
content: Buffer.from('foo').toString('base64'), | ||
contentType: 'filetype', | ||
encoding: 'base64', | ||
filename: 'foo' | ||
}, | ||
{ | ||
content: Buffer.from('foo').toString('base64'), | ||
contentType: 'filetype', | ||
encoding: 'base64', | ||
filename: 'bar' | ||
} | ||
] | ||
} | ||
}, | ||
currentContext: { ...CURRENT_CONTEXT, bearerToken: null }, | ||
headers: {} | ||
}; | ||
|
||
const emailResponse = { | ||
data: 'foo', | ||
status: 201 | ||
}; | ||
|
||
emailSpy.mockResolvedValue(emailResponse); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
await roadmapController.send(req as any, res as any, next); | ||
|
||
expect(getObjectsSpy).toHaveBeenCalledTimes(0); | ||
expect(getObjectSpy).toHaveBeenCalledTimes(0); | ||
expect(emailSpy).toHaveBeenCalledTimes(1); | ||
expect(emailSpy).toHaveBeenCalledWith(req.body.emailData); | ||
expect(res.status).toHaveBeenCalledWith(201); | ||
|
@@ -270,10 +319,10 @@ describe('send', () => { | |
await roadmapController.send(req as any, res as any, next); | ||
|
||
expect(getObjectsSpy).toHaveBeenCalledTimes(1); | ||
expect(getObjectsSpy).toHaveBeenNthCalledWith(1, req.headers, req.body.selectedFileIds); | ||
expect(getObjectsSpy).toHaveBeenNthCalledWith(1, req.currentContext.bearerToken, req.body.selectedFileIds); | ||
expect(getObjectSpy).toHaveBeenCalledTimes(2); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(1, req.headers, req.body.selectedFileIds[0]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(2, req.headers, req.body.selectedFileIds[1]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(1, req.currentContext.bearerToken, req.body.selectedFileIds[0]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(2, req.currentContext.bearerToken, req.body.selectedFileIds[1]); | ||
expect(emailSpy).toHaveBeenCalledTimes(1); | ||
expect(emailSpy).toHaveBeenCalledWith(req.body.emailData); | ||
expect(createNoteSpy).toHaveBeenCalledTimes(1); | ||
|
@@ -329,10 +378,10 @@ describe('send', () => { | |
await roadmapController.send(req as any, res as any, next); | ||
|
||
expect(getObjectsSpy).toHaveBeenCalledTimes(1); | ||
expect(getObjectsSpy).toHaveBeenNthCalledWith(1, req.headers, req.body.selectedFileIds); | ||
expect(getObjectsSpy).toHaveBeenNthCalledWith(1, req.currentContext.bearerToken, req.body.selectedFileIds); | ||
expect(getObjectSpy).toHaveBeenCalledTimes(2); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(1, req.headers, req.body.selectedFileIds[0]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(2, req.headers, req.body.selectedFileIds[1]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(1, req.currentContext.bearerToken, req.body.selectedFileIds[0]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(2, req.currentContext.bearerToken, req.body.selectedFileIds[1]); | ||
expect(emailSpy).toHaveBeenCalledTimes(0); | ||
expect(res.status).toHaveBeenCalledTimes(0); | ||
expect(next).toHaveBeenCalledTimes(1); | ||
|
@@ -389,10 +438,10 @@ describe('send', () => { | |
await roadmapController.send(req as any, res as any, next); | ||
|
||
expect(getObjectsSpy).toHaveBeenCalledTimes(1); | ||
expect(getObjectsSpy).toHaveBeenNthCalledWith(1, req.headers, req.body.selectedFileIds); | ||
expect(getObjectsSpy).toHaveBeenNthCalledWith(1, req.currentContext.bearerToken, req.body.selectedFileIds); | ||
expect(getObjectSpy).toHaveBeenCalledTimes(2); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(1, req.headers, req.body.selectedFileIds[0]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(2, req.headers, req.body.selectedFileIds[1]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(1, req.currentContext.bearerToken, req.body.selectedFileIds[0]); | ||
expect(getObjectSpy).toHaveBeenNthCalledWith(2, req.currentContext.bearerToken, req.body.selectedFileIds[1]); | ||
expect(emailSpy).toHaveBeenCalledTimes(0); | ||
expect(res.status).toHaveBeenCalledTimes(0); | ||
expect(next).toHaveBeenCalledTimes(1); | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Safety: There should be a conditional if here to drop the Authorization header completely if
bearerToken
is either null or undefined.