-
Notifications
You must be signed in to change notification settings - Fork 103
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
d9fc675
commit 55cb23e
Showing
6 changed files
with
49 additions
and
32 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
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 |
---|---|---|
|
@@ -120,15 +120,25 @@ describe('api', function () { | |
|
||
describe('events', function () { | ||
describe('when user is "foo"', () => { | ||
const username = '[email protected]' | ||
const user = fixtures.auth.createUser({ | ||
id: '[email protected]', | ||
id: username, | ||
}) | ||
let defaultRooms | ||
let args | ||
|
||
beforeEach(async () => { | ||
// authorization check for `canListProjects` | ||
mockRequest.mockImplementationOnce(fixtures.auth.mocks.reviewSelfSubjectAccess()) | ||
socket = await agent.connect({ | ||
cookie: await user.cookie, | ||
}) | ||
defaultRooms = [ | ||
socket.id, | ||
ioHelper.sha256(username), | ||
] | ||
expect(mockRequest).toHaveBeenCalledTimes(1) | ||
mockRequest.mockClear() | ||
}) | ||
|
||
it('should subscribe shoots for a single cluster', async function () { | ||
|
@@ -140,7 +150,7 @@ describe('api', function () { | |
expect(mockRequest.mock.calls).toMatchSnapshot() | ||
|
||
expect(getRooms(socket, nsp)).toEqual(new Set([ | ||
socket.id, | ||
...defaultRooms, | ||
'shoots;garden-foo/fooShoot', | ||
])) | ||
|
||
|
@@ -170,13 +180,13 @@ describe('api', function () { | |
expect(mockRequest.mock.calls).toMatchSnapshot() | ||
|
||
expect(getRooms(socket, nsp)).toEqual(new Set([ | ||
socket.id, | ||
...defaultRooms, | ||
'shoots;garden-foo', | ||
])) | ||
|
||
await unsubscribe(socket, 'shoots') | ||
expect(getRooms(socket, nsp)).toEqual(new Set([ | ||
socket.id, | ||
...defaultRooms, | ||
])) | ||
}) | ||
|
||
|
@@ -191,7 +201,7 @@ describe('api', function () { | |
expect(mockRequest.mock.calls).toMatchSnapshot() | ||
|
||
expect(getRooms(socket, nsp)).toEqual(new Set([ | ||
socket.id, | ||
...defaultRooms, | ||
'shoots;garden-foo', | ||
'shoots;garden-bar', | ||
])) | ||
|
@@ -208,7 +218,7 @@ describe('api', function () { | |
expect(mockRequest.mock.calls).toMatchSnapshot() | ||
|
||
expect(getRooms(socket, nsp)).toEqual(new Set([ | ||
socket.id, | ||
...defaultRooms, | ||
'shoots:unhealthy;garden-foo', | ||
'shoots:unhealthy;garden-bar', | ||
])) | ||
|
@@ -254,14 +264,23 @@ describe('api', function () { | |
}) | ||
|
||
describe('when user is "admin"', () => { | ||
const username = '[email protected]' | ||
const user = fixtures.auth.createUser({ | ||
id: '[email protected]', | ||
id: username, | ||
}) | ||
let defaultRooms | ||
|
||
beforeEach(async () => { | ||
mockRequest.mockImplementationOnce(fixtures.auth.mocks.reviewSelfSubjectAccess()) | ||
socket = await agent.connect({ | ||
cookie: await user.cookie, | ||
}) | ||
defaultRooms = [ | ||
socket.id, | ||
ioHelper.sha256(username), | ||
] | ||
expect(mockRequest).toHaveBeenCalledTimes(1) | ||
mockRequest.mockClear() | ||
}) | ||
|
||
it('should subscribe shoots for a single cluster', async function () { | ||
|
@@ -273,7 +292,7 @@ describe('api', function () { | |
expect(mockRequest.mock.calls).toMatchSnapshot() | ||
|
||
expect(getRooms(socket, nsp)).toEqual(new Set([ | ||
socket.id, | ||
...defaultRooms, | ||
'shoots;garden-foo/fooShoot', | ||
])) | ||
|
||
|
@@ -290,7 +309,7 @@ describe('api', function () { | |
expect(mockRequest.mock.calls).toMatchSnapshot() | ||
|
||
expect(getRooms(socket, nsp)).toEqual(new Set([ | ||
socket.id, | ||
...defaultRooms, | ||
'shoots;garden-foo', | ||
])) | ||
|
||
|
@@ -307,7 +326,7 @@ describe('api', function () { | |
expect(mockRequest.mock.calls).toMatchSnapshot() | ||
|
||
expect(getRooms(socket, nsp)).toEqual(new Set([ | ||
socket.id, | ||
...defaultRooms, | ||
'shoots:admin', | ||
])) | ||
|
||
|
@@ -324,7 +343,7 @@ describe('api', function () { | |
expect(mockRequest.mock.calls).toMatchSnapshot() | ||
|
||
expect(getRooms(socket, nsp)).toEqual(new Set([ | ||
socket.id, | ||
...defaultRooms, | ||
'shoots:unhealthy:admin', | ||
])) | ||
}) | ||
|
@@ -399,15 +418,18 @@ describe('api', function () { | |
}) | ||
|
||
it('should close the underlying connection', async function () { | ||
const username = '[email protected]' | ||
const options = { | ||
id: '[email protected]', | ||
id: username, | ||
rti: 'abcdefg', | ||
refresh_at: Math.ceil(Date.now() / 1000) + 4, | ||
} | ||
const user = fixtures.auth.createUser(options) | ||
mockRequest.mockImplementationOnce(fixtures.auth.mocks.reviewSelfSubjectAccess()) | ||
socket = await agent.connect({ | ||
cookie: await user.cookie, | ||
}) | ||
expect(mockRequest).toHaveBeenCalledTimes(1) | ||
expect(mockSetDisconnectTimeout).toHaveBeenCalledTimes(1) | ||
expect(mockSetDisconnectTimeout.mock.calls[0]).toEqual([ | ||
expect.objectContaining({ | ||
|
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