-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): demonstrate audience setting with origin
- Loading branch information
1 parent
965ce2e
commit 02fc3fe
Showing
5 changed files
with
109 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { getOriginFromHeaders } from '../../../lib/infrastructure/authentication.js'; | ||
import { expect } from '../../../tests/test-helper.js'; | ||
|
||
describe('Unit | Infrastructure | Authentication', function () { | ||
describe('#getOriginFromHeaders', function () { | ||
context('when port is HTTP standard port 80', function () { | ||
it('omits port 80', async function () { | ||
// given | ||
const headers = { | ||
'x-forwarded-proto': 'http', | ||
'x-forwarded-port': '80', | ||
'x-forwarded-host': 'localhost', | ||
}; | ||
|
||
// when | ||
const origin = getOriginFromHeaders(headers); | ||
|
||
// then | ||
expect(origin).to.equal('http://localhost'); | ||
}); | ||
}); | ||
|
||
context('when port is HTTPS standard port 443', function () { | ||
it('omits port 443', async function () { | ||
// given | ||
const headers = { | ||
'x-forwarded-proto': 'https', | ||
'x-forwarded-port': '443', | ||
'x-forwarded-host': 'app-pr10823.review.pix.fr', | ||
}; | ||
|
||
// when | ||
const origin = getOriginFromHeaders(headers); | ||
|
||
// then | ||
expect(origin).to.equal('https://app-pr10823.review.pix.fr'); | ||
}); | ||
}); | ||
|
||
context('when port is neither HTTP nor HTTPS standard ports', function () { | ||
it('includes port', async function () { | ||
// given | ||
const headers = { | ||
'x-forwarded-proto': 'http', | ||
'x-forwarded-port': '4200', | ||
'x-forwarded-host': 'localhost', | ||
}; | ||
|
||
// when | ||
const origin = getOriginFromHeaders(headers); | ||
|
||
// then | ||
expect(origin).to.equal('http://localhost:4200'); | ||
}); | ||
}); | ||
}); | ||
}); |