-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1302 from nickgros/onesage-use-localhost
- Loading branch information
Showing
11 changed files
with
260 additions
and
37 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
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
144 changes: 144 additions & 0 deletions
144
packages/synapse-react-client/src/utils/hooks/useOneSageURL.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,144 @@ | ||
import { | ||
SYNAPSE_BACKEND_DEV_URL, | ||
SYNAPSE_BACKEND_PRODUCTION_URL, | ||
SYNAPSE_BACKEND_STAGING_URL, | ||
} from '../SynapseConstants' | ||
import { getOneSageUrl } from './useOneSageURL' | ||
|
||
describe('OneSage URL tests', () => { | ||
describe('SynapseWebClient domains', () => { | ||
test('production', () => { | ||
const appId = 'synapse.org' | ||
expect( | ||
getOneSageUrl( | ||
'synapse.org', | ||
SYNAPSE_BACKEND_PRODUCTION_URL, | ||
appId, | ||
).toString(), | ||
).toEqual('https://accounts.synapse.org/?appId=synapse.org') | ||
expect( | ||
getOneSageUrl( | ||
'www.synapse.org', | ||
SYNAPSE_BACKEND_PRODUCTION_URL, | ||
appId, | ||
).toString(), | ||
).toEqual('https://accounts.synapse.org/?appId=synapse.org') | ||
}) | ||
test('staging', () => { | ||
const appId = 'staging.synapse.org' | ||
const url = getOneSageUrl( | ||
'staging.synapse.org', | ||
SYNAPSE_BACKEND_STAGING_URL, | ||
appId, | ||
) | ||
expect(url.toString()).toEqual( | ||
'https://staging.accounts.synapse.org/?appId=staging.synapse.org', | ||
) | ||
}) | ||
test.todo('dev') // IT-3849 | ||
test('local', () => { | ||
const appId = 'localhost' | ||
expect( | ||
getOneSageUrl( | ||
'127.0.0.1', | ||
SYNAPSE_BACKEND_PRODUCTION_URL, | ||
appId, | ||
).toString(), | ||
).toEqual('http://127.0.0.1:3000/?appId=localhost') | ||
expect( | ||
getOneSageUrl( | ||
'127.0.0.1', | ||
SYNAPSE_BACKEND_STAGING_URL, | ||
appId, | ||
).toString(), | ||
).toEqual('http://127.0.0.1:3000/?appId=localhost') | ||
expect( | ||
getOneSageUrl('127.0.0.1', SYNAPSE_BACKEND_DEV_URL, appId).toString(), | ||
).toEqual('http://127.0.0.1:3000/?appId=localhost') | ||
expect( | ||
getOneSageUrl( | ||
'localhost', | ||
SYNAPSE_BACKEND_PRODUCTION_URL, | ||
appId, | ||
).toString(), | ||
).toEqual('http://localhost:3000/?appId=localhost') | ||
expect( | ||
getOneSageUrl( | ||
'localhost', | ||
SYNAPSE_BACKEND_STAGING_URL, | ||
appId, | ||
).toString(), | ||
).toEqual('http://localhost:3000/?appId=localhost') | ||
expect( | ||
getOneSageUrl('localhost', SYNAPSE_BACKEND_DEV_URL, appId).toString(), | ||
).toEqual('http://localhost:3000/?appId=localhost') | ||
}) | ||
}) | ||
|
||
describe('OneSage domains', () => { | ||
test('production', () => { | ||
const url = getOneSageUrl( | ||
'accounts.synapse.org', | ||
SYNAPSE_BACKEND_PRODUCTION_URL, | ||
) | ||
expect(url.toString()).toEqual('https://accounts.synapse.org/') | ||
}) | ||
test('staging', () => { | ||
const url = getOneSageUrl( | ||
'staging.accounts.synapse.org', | ||
SYNAPSE_BACKEND_STAGING_URL, | ||
) | ||
expect(url.toString()).toEqual('https://staging.accounts.synapse.org/') | ||
}) | ||
test.todo('dev') // no site exists (IT-3849) | ||
test('local', () => { | ||
const url = getOneSageUrl('localhost', SYNAPSE_BACKEND_PRODUCTION_URL) | ||
expect(url.toString()).toEqual('http://localhost:3000/') | ||
}) | ||
}) | ||
|
||
describe('synapse-oauth-signin domains', () => { | ||
test('production', () => { | ||
const url = getOneSageUrl( | ||
'signin.synapse.org', | ||
SYNAPSE_BACKEND_PRODUCTION_URL, | ||
) | ||
expect(url.toString()).toEqual('https://accounts.synapse.org/') | ||
}) | ||
test('staging', () => { | ||
const url = getOneSageUrl( | ||
'staging-signin.synapse.org', | ||
SYNAPSE_BACKEND_STAGING_URL, | ||
) | ||
expect(url.toString()).toEqual('https://staging.accounts.synapse.org/') | ||
}) | ||
test.todo('dev') // no site exists | ||
test.todo('local') // these typically run on the same port, so we need to establish a convention to run them on different ports | ||
}) | ||
|
||
describe('portal domain', () => { | ||
const appId = 'myportal' | ||
|
||
test('production', () => { | ||
const url = getOneSageUrl( | ||
'myportal.synapse.org', | ||
SYNAPSE_BACKEND_PRODUCTION_URL, | ||
appId, | ||
) | ||
expect(url.toString()).toEqual( | ||
'https://accounts.synapse.org/?appId=myportal', | ||
) | ||
}) | ||
test('staging', () => { | ||
// Staging portals typically use Synapse production as a backend | ||
const url = getOneSageUrl( | ||
'staging.myportal.synapse.org', | ||
SYNAPSE_BACKEND_PRODUCTION_URL, | ||
appId, | ||
) | ||
expect(url.toString()).toEqual( | ||
'https://accounts.synapse.org/?appId=myportal', | ||
) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.