Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
# the behavior to use the new URLs.
CHROMEDRIVER_CDNURL: https://googlechromelabs.github.io/
CHROMEDRIVER_CDNBINARIESURL: https://storage.googleapis.com/chrome-for-testing-public
CHROME_VALIDATED_VERSION: linux-132.0.6834.110
CHROME_VALIDATED_VERSION: linux-137.0.0.0
CHROME_VERSION_MISMATCH_MESSAGE: "The Chrome version doesn't match the previously validated version. Consider updating CHROME_VALIDATED_VERSION in the GitHub workflow if tests pass, or rollback the installed Chrome version if tests fail."
artifactRetentionDays: 14
# Bump Node memory limit
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-changed-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
# the behavior to use the new URLs.
CHROMEDRIVER_CDNURL: https://googlechromelabs.github.io/
CHROMEDRIVER_CDNBINARIESURL: https://storage.googleapis.com/chrome-for-testing-public
CHROME_VALIDATED_VERSION: linux-120.0.6099.71
CHROME_VALIDATED_VERSION: linux-137.0.7151.119
# Bump Node memory limit
NODE_OPTIONS: "--max_old_space_size=4096"

Expand Down Expand Up @@ -119,4 +119,4 @@ jobs:
- name: Run tests on changed packages
run: yarn test:changed auth
env:
BROWSERS: 'WebkitHeadless'
BROWSERS: 'WebkitHeadless'
8 changes: 6 additions & 2 deletions packages/auth/src/api/authentication/exchange_token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ describe('api/authentication/exchange_token', () => {
let regionalAuth: TestAuth;
const request = {
parent: 'test-parent',
token: 'custom-token'
// eslint-disable-next-line camelcase
id_token: 'custom-token'
};

beforeEach(async () => {
Expand All @@ -52,6 +53,7 @@ describe('api/authentication/exchange_token', () => {
const mock = mockRegionalEndpointWithParent(
RegionalEndpoint.EXCHANGE_TOKEN,
'test-parent',
'test-api-key',
{ accessToken: 'outbound-token', expiresIn: '1000' }
);

Expand All @@ -60,7 +62,8 @@ describe('api/authentication/exchange_token', () => {
expect(response.expiresIn).equal('1000');
expect(mock.calls[0].request).to.eql({
parent: 'test-parent',
token: 'custom-token'
// eslint-disable-next-line camelcase
id_token: 'custom-token'
});
expect(mock.calls[0].method).to.eq('POST');
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
Expand All @@ -79,6 +82,7 @@ describe('api/authentication/exchange_token', () => {
const mock = mockRegionalEndpointWithParent(
RegionalEndpoint.EXCHANGE_TOKEN,
'test-parent',
'test-api-key',
{
error: {
code: 400,
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/api/authentication/exchange_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Auth } from '../../model/public_types';

export interface ExchangeTokenRequest {
parent: string;
token: string;
id_token: string;
}

export interface ExchangeTokenResponse {
Expand Down
2 changes: 2 additions & 0 deletions packages/auth/src/api/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ describe('api/_performRegionalApiRequest', () => {
const mock = mockRegionalEndpointWithParent(
RegionalEndpoint.EXCHANGE_TOKEN,
'test-parent',
'test-api-key',
serverResponse
);
const response = await _performRegionalApiRequest<
Expand Down Expand Up @@ -689,6 +690,7 @@ describe('api/_performRegionalApiRequest', () => {
const mock = mockRegionalEndpointWithParent(
RegionalEndpoint.EXCHANGE_TOKEN,
'test-parent',
'test-api-key',
serverResponse
);
await _performRegionalApiRequest<typeof request, typeof serverResponse>(
Expand Down
15 changes: 4 additions & 11 deletions packages/auth/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,10 @@ async function performApiRequest<T, V>(
}
}

let queryParamString: string;
if (isRegionalAuthInitialized(auth)) {
queryParamString = querystring({
...params
}).slice(1);
} else {
queryParamString = querystring({
key: auth.config.apiKey,
...params
}).slice(1);
}
const queryParamString = querystring({
key: auth.config.apiKey,
...params
}).slice(1);

const headers = await (auth as AuthInternal)._getAdditionalHeaders();
headers[HttpHeader.CONTENT_TYPE] = 'application/json';
Expand Down
8 changes: 6 additions & 2 deletions packages/auth/src/core/strategies/exchange_token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('core/strategies/exchangeToken', () => {
const mock = mockRegionalEndpointWithParent(
RegionalEndpoint.EXCHANGE_TOKEN,
'projects/test-project-id/locations/us/tenants/tenant-1/idpConfigs/idp-config',
'test-api-key',
{ accessToken: 'outbound-token', expiresIn: 10 }
);

Expand All @@ -64,7 +65,8 @@ describe('core/strategies/exchangeToken', () => {
expect(mock.calls[0].request).to.eql({
parent:
'projects/test-project-id/locations/us/tenants/tenant-1/idpConfigs/idp-config',
token: 'custom-token'
// eslint-disable-next-line camelcase
id_token: 'custom-token'
});
expect(mock.calls[0].method).to.eq('POST');
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
Expand All @@ -87,6 +89,7 @@ describe('core/strategies/exchangeToken', () => {
const mock = mockRegionalEndpointWithParent(
RegionalEndpoint.EXCHANGE_TOKEN,
'projects/test-project-id/locations/us/tenants/tenant-1/idpConfigs/idp-config',
'test-api-key',
{
error: {
code: 400,
Expand All @@ -107,7 +110,8 @@ describe('core/strategies/exchangeToken', () => {
expect(mock.calls[0].request).to.eql({
parent:
'projects/test-project-id/locations/us/tenants/tenant-1/idpConfigs/idp-config',
token: 'custom-token'
// eslint-disable-next-line camelcase
id_token: 'custom-token'
});
expect(mock.calls[0].method).to.eq('POST');
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
Expand Down
3 changes: 2 additions & 1 deletion packages/auth/src/core/strategies/exhange_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export async function exchangeToken(
const authInternal = _castAuth(auth);
const token = await getToken(authInternal, {
parent: buildParent(auth, idpConfigId),
token: customToken
// eslint-disable-next-line camelcase
id_token: customToken
});
if (token) {
await authInternal._updateFirebaseToken({
Expand Down
6 changes: 4 additions & 2 deletions packages/auth/test/helpers/api/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ export function mockEndpointWithParams(
export function mockRegionalEndpointWithParent(
endpoint: RegionalEndpoint,
parent: string,
key: string,
response: object,
status = 200
): Route {
const url = `${TEST_SCHEME}://${TEST_HOST}${parent}${endpoint}`;
console.log('here ', url);
let url = `${TEST_SCHEME}://${TEST_HOST}${parent}${endpoint}`;
url += '?key=';
url += key;
return mock(url, response, status);
}
Loading