-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5cc589
commit 63c71b8
Showing
9 changed files
with
61 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,5 +40,10 @@ | |
"sequelize": "^6.28.0", | ||
"umzug": "^3.2.1", | ||
"winston": "^3.8.2" | ||
}, | ||
"nodemonConfig": { | ||
"ignore": [ | ||
"tests" | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { Router } = require('express') | ||
const User = require('../db/models/user') | ||
|
||
const testRouter = Router() | ||
|
||
testRouter.post('/users', (req, res) => { | ||
const users = req.body | ||
|
||
User.bulkCreate(users) | ||
|
||
res.status(201).json(users) | ||
}) | ||
|
||
module.exports = testRouter |
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 |
---|---|---|
@@ -1,9 +1,26 @@ | ||
import { expect, test } from 'vitest' | ||
import { expect, test, beforeAll } from 'vitest' | ||
import { baseUrl } from './config' | ||
import { seed } from './seed' | ||
|
||
const baseUrl = 'http://localhost:3000' | ||
beforeAll(async () => { | ||
await seed() | ||
}) | ||
|
||
test('Ping', async () => { | ||
const res = await fetch(`${baseUrl}/ping`) | ||
expect(res.status).toBe(200) | ||
expect(await res.text()).toBe('pong') | ||
}) | ||
|
||
test('User with no iam groups gets no access', async () => { | ||
const res = await fetch(baseUrl, { | ||
body: JSON.stringify({ userId: 'user-1', iamGroups: [] }), | ||
method: 'POST', | ||
}) | ||
|
||
expect(res.status).toBe(200) | ||
expect(await res.json()).toEqual({ | ||
// access: {}, <-- this is the expected response. Fix api. | ||
specialGroup: {}, | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export const baseUrl = 'http://localhost:3000' |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const NO_RIGHTS_USER = { | ||
id: 'user-1', | ||
iamGroups: [], | ||
} | ||
|
||
export const ALL_USERS = [NO_RIGHTS_USER] |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { baseUrl } from './config' | ||
import { ALL_USERS } from './data' | ||
|
||
export const seed = async () => { | ||
await fetch(`${baseUrl}/test/users`, { | ||
body: ALL_USERS, | ||
method: 'POST', | ||
}) | ||
} |