-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: enable subdomain authentication test in ci (#13733)
* wip: hardcode signout uri for poc * chore: expose the prefferedRedirectSignOutUrl * chore: add prefered url change to native file * chore: correct param name * chore: update getRedirectUrl function to consider preferred url * chore: add unit test for the feature * chore: update input type to use the accepted format * chore: review comments * fix: address npm audit issues * chore: update comments, bundle size and rn version * chore: update bundle size limit * chore: update bundle size limit * chore: address coments and rename a param to getRedirecturl funciton * chore: make preid release ready * chore: update yarn.lock * chore: add test and update push-integ branch * chore: revert preid release updates * chore: update sample name * chore: update yarn.lock * chore(auth): add oauth metadata into token orchestrator (#13712) * chore: add oauth metadata into token orchestrator * chore: add unit tests * chore: address feedback * chore: fix unit tests * chore: enable tests in ci --------- Co-authored-by: ManojNB <[email protected]>
- Loading branch information
1 parent
5224dc2
commit 3ab9863
Showing
28 changed files
with
425 additions
and
1,314 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -138,5 +138,8 @@ | |
"xml2js": "0.5.0", | ||
"tar": "6.2.1", | ||
"glob@^10.0.0": "10.3.10" | ||
}, | ||
"overrides": { | ||
"tar": "6.2.1" | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
packages/auth/__tests__/providers/cognito/utils/oauth/getRedirectUrl.native.test.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { invalidAppSchemeException } from '../../../../../src/errors/constants'; | ||
import { getRedirectUrl } from '../../../../../src/providers/cognito/utils/oauth/getRedirectUrl.native'; | ||
|
||
describe('getRedirectUrl (native)', () => { | ||
const mockRedirectUrls = [ | ||
'myDevApp://', | ||
'myProdApp://', | ||
'https://intermidiateSite.com', | ||
]; | ||
|
||
it('should return the first non http/s url from the array when preferredRedirectUrl is not provided', () => { | ||
expect(getRedirectUrl(mockRedirectUrls)).toStrictEqual(mockRedirectUrls[0]); | ||
}); | ||
|
||
it('should return preferredRedirectUrl if it matches at least one of the redirect urls from config', () => { | ||
const configRedirectUrl = mockRedirectUrls[2]; | ||
|
||
expect(getRedirectUrl(mockRedirectUrls, configRedirectUrl)).toStrictEqual( | ||
configRedirectUrl, | ||
); | ||
}); | ||
|
||
it('should throw an exception when there is no url with no http or https as prefix irrespective if a preferredSignOutUrl is given or not', () => { | ||
const mockRedirectUrlsWithNoAppScheme = ['https://intermidiateSite.com']; | ||
expect(() => | ||
getRedirectUrl( | ||
mockRedirectUrlsWithNoAppScheme, | ||
mockRedirectUrlsWithNoAppScheme[0], | ||
), | ||
).toThrow(invalidAppSchemeException); | ||
expect(() => getRedirectUrl(mockRedirectUrlsWithNoAppScheme)).toThrow( | ||
invalidAppSchemeException, | ||
); | ||
}); | ||
}); |
66 changes: 66 additions & 0 deletions
66
packages/auth/__tests__/providers/cognito/utils/oauth/getRedirectUrl.test.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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { getRedirectUrl } from '../../../../../src/providers/cognito/utils/oauth'; | ||
import { | ||
invalidOriginException, | ||
invalidPreferredRedirectUrlException, | ||
invalidRedirectException, | ||
} from '../../../../../src/errors/constants'; | ||
|
||
describe('getRedirectUrl', () => { | ||
const mockRedirectUrls = ['https://example.com/app']; | ||
let windowSpy: jest.SpyInstance; | ||
|
||
beforeEach(() => { | ||
windowSpy = jest.spyOn(window, 'window', 'get'); | ||
}); | ||
|
||
afterEach(() => { | ||
windowSpy.mockRestore(); | ||
}); | ||
|
||
it('should return the redirect url that has the same origin and same pathName', () => { | ||
windowSpy.mockReturnValue({ | ||
location: { | ||
origin: 'https://example.com/', | ||
pathname: 'app', | ||
}, | ||
}); | ||
expect(getRedirectUrl(mockRedirectUrls)).toStrictEqual(mockRedirectUrls[0]); | ||
}); | ||
|
||
it('should throw an invalid origin exception if there is no url that is the same origin and pathname', () => { | ||
windowSpy.mockReturnValue({ | ||
location: { | ||
origin: 'https://differentOrigin.com/', | ||
pathname: 'differentApp', | ||
}, | ||
}); | ||
expect(() => getRedirectUrl(mockRedirectUrls)).toThrow( | ||
invalidOriginException, | ||
); | ||
}); | ||
|
||
it('should throw an invalid redirect exception if there is no url that is the same origin/pathname and is also not http or https', () => { | ||
const mockNonHttpRedirectUrls = ['test-non-http-string']; | ||
windowSpy.mockReturnValue({ | ||
location: { | ||
origin: 'https://differentOrigin.com/', | ||
pathname: 'differentApp', | ||
}, | ||
}); | ||
expect(() => getRedirectUrl(mockNonHttpRedirectUrls)).toThrow( | ||
invalidRedirectException, | ||
); | ||
}); | ||
|
||
it('should return the preferredRedirectUrl if it is provided and matches one of the redirectUrls from config', () => { | ||
expect(getRedirectUrl(mockRedirectUrls, mockRedirectUrls[0])).toStrictEqual( | ||
mockRedirectUrls[0], | ||
); | ||
}); | ||
|
||
it('should throw an exception if preferredRedirectUrl is given but does not match any of the redirectUrls from config', () => { | ||
expect(() => | ||
getRedirectUrl(mockRedirectUrls, 'https://unknownOrigin.com'), | ||
).toThrow(invalidPreferredRedirectUrlException); | ||
}); | ||
}); |
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
Oops, something went wrong.