-
Notifications
You must be signed in to change notification settings - Fork 2
feat: validate token in sticker-catalogue and sticker-award #167
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
44c4a00
chore(web-frontend): include auth header on API calls
scottgerring 19f33dc
feat(sticker-catalogue): validate tokens
scottgerring 402a2a2
feat(sticker-award): validate tokens
scottgerring 7b0e936
fix e2e test issues
scottgerring c247d4b
chore: don't force user-service dep on everything
scottgerring 38b47c6
chore: more bug fixes for auth
scottgerring 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| test.describe('API Authentication Requirements', () => { | ||
|
Member
Author
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. Added tests to validate |
||
| test.describe('Sticker Catalogue - Protected Endpoints', () => { | ||
| test('POST /api/stickers/v1/ requires authentication', async ({ request }) => { | ||
| const response = await request.post('/api/stickers/v1/', { | ||
| data: { | ||
| stickerName: 'Test Sticker', | ||
| stickerDescription: 'A test sticker', | ||
| }, | ||
| }); | ||
| expect(response.status()).toBe(401); | ||
| }); | ||
|
|
||
| test('PUT /api/stickers/v1/{id} requires authentication', async ({ request }) => { | ||
| const response = await request.put('/api/stickers/v1/sticker-001', { | ||
| data: { | ||
| stickerName: 'Updated Sticker', | ||
| }, | ||
| }); | ||
| expect(response.status()).toBe(401); | ||
| }); | ||
|
|
||
| test('DELETE /api/stickers/v1/{id} requires authentication', async ({ request }) => { | ||
| const response = await request.delete('/api/stickers/v1/sticker-001'); | ||
| expect(response.status()).toBe(401); | ||
| }); | ||
|
|
||
| test('POST /api/stickers/v1/{id}/image requires authentication', async ({ request }) => { | ||
| const response = await request.post('/api/stickers/v1/sticker-001/image', { | ||
| headers: { | ||
| 'Content-Type': 'image/png', | ||
| }, | ||
| data: Buffer.from('fake-image-data'), | ||
| }); | ||
| expect(response.status()).toBe(401); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('Sticker Catalogue - Public Endpoints', () => { | ||
| test('GET /api/stickers/v1/ does not require authentication', async ({ request }) => { | ||
| const response = await request.get('/api/stickers/v1/'); | ||
| expect(response.ok()).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('GET /api/stickers/v1/{id} does not require authentication', async ({ request }) => { | ||
| const response = await request.get('/api/stickers/v1/sticker-001'); | ||
| expect(response.ok()).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('GET /api/stickers/v1/{id}/image does not require authentication', async ({ request }) => { | ||
| const response = await request.get('/api/stickers/v1/sticker-001/image'); | ||
| expect(response.ok()).toBeTruthy(); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('Sticker Award - Protected Endpoints', () => { | ||
| test('POST /api/awards/v1/assignments/{userId} requires authentication', async ({ request }) => { | ||
| const response = await request.post('/api/awards/v1/assignments/user-001', { | ||
| data: { | ||
| stickerId: 'sticker-001', | ||
| }, | ||
| }); | ||
| expect(response.status()).toBe(401); | ||
| }); | ||
|
|
||
| test('DELETE /api/awards/v1/assignments/{userId}/{stickerId} requires authentication', async ({ request }) => { | ||
| const response = await request.delete('/api/awards/v1/assignments/user-001/sticker-001'); | ||
| expect(response.status()).toBe(401); | ||
| }); | ||
| }); | ||
|
|
||
| test('GET /api/awards/v1/assignments/{userId} requires authentication', async ({ request }) => { | ||
| const response = await request.get('/api/awards/v1/assignments/user-001'); | ||
| expect(response.status()).toBe(401); | ||
| }); | ||
| }); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Do you think we look into OpenIddict config to try and fix it? Or just live with it?
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.
i don't think it's really broken, i think we just need to be actively consistent. This seems to be the easier way around - i stuffed about trying to get dotnet to not append
/, but ultimately I don't care which way it goes, as long as they are all the same!