-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix query param handling in AuthService.signInCallback
- Loading branch information
Showing
5 changed files
with
39 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
Bugfix: Open files in external app | ||
|
||
We've fixed a bug that caused office documents not to be opened in app provider editors anymore. | ||
We've fixed bugs that caused office documents not to be opened in app provider editors anymore. | ||
|
||
https://github.com/owncloud/web/pull/8705 | ||
https://github.com/owncloud/web/issues/8695 | ||
https://github.com/owncloud/web/pull/8705 | ||
https://github.com/owncloud/web/issues/8773 | ||
https://github.com/owncloud/web/pull/8782 |
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
48 changes: 31 additions & 17 deletions
48
packages/web-runtime/tests/unit/services/auth/authService.spec.ts
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,27 +1,41 @@ | ||
import { AuthService } from 'web-runtime/src/services/auth/authService' | ||
import { createRouter } from 'web-test-helpers/src' | ||
|
||
describe('AuthService', () => { | ||
describe('signInCallback', () => { | ||
it.each([ | ||
[{ details: 'details' }, { details: 'details' }], | ||
[{ details: 'details', unknown: 'unknown' }, { details: 'details' }], | ||
[{ unknown: 'unknown' }, {}] | ||
])('forwards only whitelisted query parameters: %s = %s', async (query, expected: any) => { | ||
const authService = new AuthService() | ||
const replace = jest.fn() | ||
['/', '/', {}], | ||
['/?details=sharing', '/', { details: 'sharing' }], | ||
[ | ||
'/external?contextRouteName=files-spaces-personal&fileId=0f897576', | ||
'/external', | ||
{ | ||
contextRouteName: 'files-spaces-personal', | ||
fileId: '0f897576' | ||
} | ||
] | ||
])( | ||
'parses query params and passes them explicitly to router.replace: %s => %s %s', | ||
async (url, path, query: any) => { | ||
const authService = new AuthService() | ||
|
||
jest.replaceProperty(authService as any, 'userManager', { | ||
signinRedirectCallback: jest.fn(), | ||
getAndClearPostLoginRedirectUrl: jest.fn() | ||
}) | ||
jest.replaceProperty(authService as any, 'userManager', { | ||
signinRedirectCallback: jest.fn(), | ||
getAndClearPostLoginRedirectUrl: () => url | ||
}) | ||
|
||
jest.replaceProperty(authService as any, 'router', { | ||
currentRoute: { query }, | ||
replace | ||
}) | ||
await authService.signInCallback() | ||
const router = createRouter() | ||
const replaceSpy = jest.spyOn(router, 'replace') | ||
|
||
expect(replace.mock.calls[0][0].query).toEqual(expected) | ||
}) | ||
authService.initialize(null, null, null, router, null, null) | ||
|
||
await authService.signInCallback() | ||
|
||
expect(replaceSpy).toHaveBeenCalledWith({ | ||
path, | ||
query | ||
}) | ||
} | ||
) | ||
}) | ||
}) |