Skip to content

Commit 12f439e

Browse files
committed
Pass in SDK version & correctly send GET request params
1 parent 97114a9 commit 12f439e

30 files changed

+160
-141
lines changed

packages-exp/auth-exp/src/api/account_management/account.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { FirebaseError } from '@firebase/util';
1819
import { expect, use } from 'chai';
1920
import * as chaiAsPromised from 'chai-as-promised';
20-
import { deleteAccount, deleteLinkedAccounts, getAccountInfo } from './account';
2121
import { Endpoint } from '..';
22-
import { ServerError } from '../errors';
23-
import { FirebaseError } from '@firebase/util';
22+
import { mockEndpoint } from '../../../test/api/helper';
23+
import { mockAuth } from '../../../test/mock_auth';
2424
import * as mockFetch from '../../../test/mock_fetch';
25-
import { mockEndpoint, mockAuth } from '../../../test/api/helper';
2625
import { ProviderId } from '../../core/providers';
26+
import { ServerError } from '../errors';
27+
import { deleteAccount, deleteLinkedAccounts, getAccountInfo } from './account';
2728

2829
use(chaiAsPromised);
2930

@@ -42,7 +43,8 @@ describe('deleteAccount', () => {
4243
expect(mock.calls[0].request).to.eql(request);
4344
expect(mock.calls[0].method).to.eq('POST');
4445
expect(mock.calls[0].headers).to.eql({
45-
'Content-Type': 'application/json'
46+
'Content-Type': 'application/json',
47+
'X-Client-Version': 'testSDK/0.0.0'
4648
});
4749
});
4850

@@ -94,7 +96,8 @@ describe('deleteLinkedAccounts', () => {
9496
expect(mock.calls[0].request).to.eql(request);
9597
expect(mock.calls[0].method).to.eq('POST');
9698
expect(mock.calls[0].headers).to.eql({
97-
'Content-Type': 'application/json'
99+
'Content-Type': 'application/json',
100+
'X-Client-Version': 'testSDK/0.0.0'
98101
});
99102
});
100103

@@ -145,7 +148,8 @@ describe('getAccountInfo', () => {
145148
expect(mock.calls[0].request).to.eql(request);
146149
expect(mock.calls[0].method).to.eq('POST');
147150
expect(mock.calls[0].headers).to.eql({
148-
'Content-Type': 'application/json'
151+
'Content-Type': 'application/json',
152+
'X-Client-Version': 'testSDK/0.0.0'
149153
});
150154
});
151155

packages-exp/auth-exp/src/api/account_management/account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { Endpoint, HttpMethod, performApiRequest } from '..';
1819
import { Auth } from '../../model/auth';
19-
import { performApiRequest, HttpMethod, Endpoint } from '..';
2020
import { APIMFAInfo } from '../../model/id_token';
2121

2222
export interface DeleteAccountRequest {

packages-exp/auth-exp/src/api/account_management/email_and_password.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { FirebaseError } from '@firebase/util';
1819
import { expect, use } from 'chai';
1920
import * as chaiAsPromised from 'chai-as-promised';
20-
import { resetPassword, updateEmailPassword } from './email_and_password';
2121
import { Endpoint } from '..';
22-
import { ServerError } from '../errors';
23-
import { FirebaseError } from '@firebase/util';
22+
import { mockEndpoint } from '../../../test/api/helper';
23+
import { mockAuth } from '../../../test/mock_auth';
2424
import * as mockFetch from '../../../test/mock_fetch';
25-
import { mockEndpoint, mockAuth } from '../../../test/api/helper';
25+
import { ServerError } from '../errors';
26+
import { resetPassword, updateEmailPassword } from './email_and_password';
2627

2728
use(chaiAsPromised);
2829

@@ -45,7 +46,8 @@ describe('resetPassword', () => {
4546
expect(mock.calls[0].request).to.eql(request);
4647
expect(mock.calls[0].method).to.eq('POST');
4748
expect(mock.calls[0].headers).to.eql({
48-
'Content-Type': 'application/json'
49+
'Content-Type': 'application/json',
50+
'X-Client-Version': 'testSDK/0.0.0'
4951
});
5052
});
5153

@@ -96,7 +98,8 @@ describe('updateEmailPassword', () => {
9698
expect(mock.calls[0].request).to.eql(request);
9799
expect(mock.calls[0].method).to.eq('POST');
98100
expect(mock.calls[0].headers).to.eql({
99-
'Content-Type': 'application/json'
101+
'Content-Type': 'application/json',
102+
'X-Client-Version': 'testSDK/0.0.0'
100103
});
101104
});
102105

packages-exp/auth-exp/src/api/account_management/email_and_password.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { performApiRequest, Endpoint, HttpMethod } from '..';
18+
import { Endpoint, HttpMethod, performApiRequest } from '..';
19+
import { Operation } from '../../model/action_code_info';
1920
import { Auth } from '../../model/auth';
2021
import { IdTokenResponse } from '../../model/id_token';
21-
import { Operation } from '../../model/action_code_info';
2222

2323
export interface ResetPasswordRequest {
2424
oobCode: string;

packages-exp/auth-exp/src/api/account_management/mfa.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { FirebaseError } from '@firebase/util';
1819
import { expect, use } from 'chai';
1920
import * as chaiAsPromised from 'chai-as-promised';
20-
import { startEnrollPhoneMfa, enrollPhoneMfa, withdrawMfa } from './mfa';
2121
import { Endpoint } from '..';
22-
import { ServerError } from '../errors';
23-
import { FirebaseError } from '@firebase/util';
22+
import { mockEndpoint } from '../../../test/api/helper';
23+
import { mockAuth } from '../../../test/mock_auth';
2424
import * as mockFetch from '../../../test/mock_fetch';
25-
import { mockEndpoint, mockAuth } from '../../../test/api/helper';
25+
import { ServerError } from '../errors';
26+
import { enrollPhoneMfa, startEnrollPhoneMfa, withdrawMfa } from './mfa';
2627

2728
use(chaiAsPromised);
2829

@@ -50,7 +51,8 @@ describe('startEnrollPhoneMfa', () => {
5051
expect(mock.calls[0].request).to.eql(request);
5152
expect(mock.calls[0].method).to.eq('POST');
5253
expect(mock.calls[0].headers).to.eql({
53-
'Content-Type': 'application/json'
54+
'Content-Type': 'application/json',
55+
'X-Client-Version': 'testSDK/0.0.0'
5456
});
5557
});
5658

@@ -104,7 +106,8 @@ describe('enrollPhoneMfa', () => {
104106
expect(mock.calls[0].request).to.eql(request);
105107
expect(mock.calls[0].method).to.eq('POST');
106108
expect(mock.calls[0].headers).to.eql({
107-
'Content-Type': 'application/json'
109+
'Content-Type': 'application/json',
110+
'X-Client-Version': 'testSDK/0.0.0'
108111
});
109112
});
110113

@@ -154,7 +157,8 @@ describe('withdrawMfa', () => {
154157
expect(mock.calls[0].request).to.eql(request);
155158
expect(mock.calls[0].method).to.eq('POST');
156159
expect(mock.calls[0].headers).to.eql({
157-
'Content-Type': 'application/json'
160+
'Content-Type': 'application/json',
161+
'X-Client-Version': 'testSDK/0.0.0'
158162
});
159163
});
160164

packages-exp/auth-exp/src/api/account_management/mfa.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
*/
1717

1818
import { Endpoint, HttpMethod, performApiRequest } from '..';
19-
import { SignInWithPhoneNumberRequest } from '../authentication/sms';
20-
import { IdTokenResponse } from '../../model/id_token';
2119
import { Auth } from '../../model/auth';
20+
import { IdTokenResponse } from '../../model/id_token';
21+
import { SignInWithPhoneNumberRequest } from '../authentication/sms';
2222

2323
export interface StartPhoneMfaEnrollmentRequest {
2424
idToken: string;

packages-exp/auth-exp/src/api/account_management/profile.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { FirebaseError } from '@firebase/util';
1819
import { expect, use } from 'chai';
1920
import * as chaiAsPromised from 'chai-as-promised';
20-
import { updateProfile } from './profile';
2121
import { Endpoint } from '..';
22-
import { ServerError } from '../errors';
23-
import { FirebaseError } from '@firebase/util';
22+
import { mockEndpoint } from '../../../test/api/helper';
23+
import { mockAuth } from '../../../test/mock_auth';
2424
import * as mockFetch from '../../../test/mock_fetch';
25-
import { mockEndpoint, mockAuth } from '../../../test/api/helper';
25+
import { ServerError } from '../errors';
26+
import { updateProfile } from './profile';
2627

2728
use(chaiAsPromised);
2829

@@ -47,7 +48,8 @@ describe('updateProfile', () => {
4748
expect(mock.calls[0].request).to.eql(request);
4849
expect(mock.calls[0].method).to.eq('POST');
4950
expect(mock.calls[0].headers).to.eql({
50-
'Content-Type': 'application/json'
51+
'Content-Type': 'application/json',
52+
'X-Client-Version': 'testSDK/0.0.0'
5153
});
5254
});
5355

packages-exp/auth-exp/src/api/account_management/profile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { IdTokenResponse } from '../../model/id_token';
18+
import { Endpoint, HttpMethod, performApiRequest } from '..';
1919
import { Auth } from '../../model/auth';
20-
import { performApiRequest, HttpMethod, Endpoint } from '..';
20+
import { IdTokenResponse } from '../../model/id_token';
2121

2222
export interface UpdateProfileRequest {
2323
idToken: string;

packages-exp/auth-exp/src/api/authentication/create_auth_uri.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { FirebaseError } from '@firebase/util';
1819
import { expect, use } from 'chai';
1920
import * as chaiAsPromised from 'chai-as-promised';
20-
import { createAuthUri } from './create_auth_uri';
2121
import { Endpoint } from '..';
22-
import { ServerError } from '../errors';
23-
import { FirebaseError } from '@firebase/util';
22+
import { mockEndpoint } from '../../../test/api/helper';
23+
import { mockAuth } from '../../../test/mock_auth';
2424
import * as mockFetch from '../../../test/mock_fetch';
25-
import { mockEndpoint, mockAuth } from '../../../test/api/helper';
25+
import { ServerError } from '../errors';
26+
import { createAuthUri } from './create_auth_uri';
2627

2728
use(chaiAsPromised);
2829

@@ -45,7 +46,8 @@ describe('createAuthUri', () => {
4546
expect(mock.calls[0].request).to.eql(request);
4647
expect(mock.calls[0].method).to.eq('POST');
4748
expect(mock.calls[0].headers).to.eql({
48-
'Content-Type': 'application/json'
49+
'Content-Type': 'application/json',
50+
'X-Client-Version': 'testSDK/0.0.0'
4951
});
5052
});
5153

packages-exp/auth-exp/src/api/authentication/create_auth_uri.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { Endpoint, HttpMethod, performApiRequest } from '..';
1819
import { Auth } from '../../model/auth';
19-
import { performApiRequest, HttpMethod, Endpoint } from '..';
2020

2121
export interface CreateAuthUriRequest {
2222
identifier: string;

packages-exp/auth-exp/src/api/authentication/custom_token.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { FirebaseError } from '@firebase/util';
1819
import { expect, use } from 'chai';
1920
import * as chaiAsPromised from 'chai-as-promised';
20-
import { signInWithCustomToken } from './custom_token';
2121
import { Endpoint } from '..';
22-
import { ServerError } from '../errors';
23-
import { FirebaseError } from '@firebase/util';
22+
import { mockEndpoint } from '../../../test/api/helper';
23+
import { mockAuth } from '../../../test/mock_auth';
2424
import * as mockFetch from '../../../test/mock_fetch';
25-
import { mockEndpoint, mockAuth } from '../../../test/api/helper';
2625
import { ProviderId } from '../../core/providers';
26+
import { ServerError } from '../errors';
27+
import { signInWithCustomToken } from './custom_token';
2728

2829
use(chaiAsPromised);
2930

@@ -51,7 +52,8 @@ describe('signInWithCustomToken', () => {
5152
expect(mock.calls[0].request).to.eql(request);
5253
expect(mock.calls[0].method).to.eq('POST');
5354
expect(mock.calls[0].headers).to.eql({
54-
'Content-Type': 'application/json'
55+
'Content-Type': 'application/json',
56+
'X-Client-Version': 'testSDK/0.0.0'
5557
});
5658
});
5759

packages-exp/auth-exp/src/api/authentication/custom_token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { Endpoint, HttpMethod, performSignInRequest } from '..';
1819
import { Auth } from '../../model/auth';
1920
import { IdTokenResponse } from '../../model/id_token';
20-
import { performSignInRequest, HttpMethod, Endpoint } from '..';
2121

2222
export interface SignInWithCustomTokenRequest {
2323
token: string;

packages-exp/auth-exp/src/api/authentication/email_and_password.test.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { FirebaseError } from '@firebase/util';
1819
import { expect, use } from 'chai';
1920
import * as chaiAsPromised from 'chai-as-promised';
20-
import {
21-
signInWithPassword,
22-
sendPasswordResetEmail,
23-
sendEmailVerification,
24-
sendSignInLinkToEmail,
25-
GetOobCodeRequestType,
26-
VerifyEmailRequest,
27-
PasswordResetRequest,
28-
EmailSignInRequest
29-
} from './email_and_password';
3021
import { Endpoint } from '..';
31-
import { ServerError } from '../errors';
32-
import { FirebaseError } from '@firebase/util';
22+
import { mockEndpoint } from '../../../test/api/helper';
23+
import { mockAuth } from '../../../test/mock_auth';
3324
import * as mockFetch from '../../../test/mock_fetch';
34-
import { mockEndpoint, mockAuth } from '../../../test/api/helper';
25+
import { ServerError } from '../errors';
26+
import { EmailSignInRequest, GetOobCodeRequestType, PasswordResetRequest, sendEmailVerification, sendPasswordResetEmail, sendSignInLinkToEmail, signInWithPassword, VerifyEmailRequest } from './email_and_password';
3527

3628
use(chaiAsPromised);
3729

@@ -57,7 +49,8 @@ describe('signInWithPassword', () => {
5749
expect(mock.calls[0].request).to.eql(request);
5850
expect(mock.calls[0].method).to.eq('POST');
5951
expect(mock.calls[0].headers).to.eql({
60-
'Content-Type': 'application/json'
52+
'Content-Type': 'application/json',
53+
'X-Client-Version': 'testSDK/0.0.0'
6154
});
6255
});
6356

@@ -106,7 +99,8 @@ describe('sendOobCode', () => {
10699
expect(mock.calls[0].request).to.eql(request);
107100
expect(mock.calls[0].method).to.eq('POST');
108101
expect(mock.calls[0].headers).to.eql({
109-
'Content-Type': 'application/json'
102+
'Content-Type': 'application/json',
103+
'X-Client-Version': 'testSDK/0.0.0'
110104
});
111105
});
112106

@@ -154,7 +148,8 @@ describe('sendOobCode', () => {
154148
expect(mock.calls[0].request).to.eql(request);
155149
expect(mock.calls[0].method).to.eq('POST');
156150
expect(mock.calls[0].headers).to.eql({
157-
'Content-Type': 'application/json'
151+
'Content-Type': 'application/json',
152+
'X-Client-Version': 'testSDK/0.0.0'
158153
});
159154
});
160155

@@ -204,7 +199,8 @@ describe('sendOobCode', () => {
204199
expect(mock.calls[0].request).to.eql(request);
205200
expect(mock.calls[0].method).to.eq('POST');
206201
expect(mock.calls[0].headers).to.eql({
207-
'Content-Type': 'application/json'
202+
'Content-Type': 'application/json',
203+
'X-Client-Version': 'testSDK/0.0.0'
208204
});
209205
});
210206

packages-exp/auth-exp/src/api/authentication/email_and_password.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { Endpoint, HttpMethod, performApiRequest, performSignInRequest } from '..';
1819
import { Auth } from '../../model/auth';
19-
import { IdTokenResponse, IdToken } from '../../model/id_token';
20-
import {
21-
performSignInRequest,
22-
HttpMethod,
23-
Endpoint,
24-
performApiRequest
25-
} from '..';
20+
import { IdToken, IdTokenResponse } from '../../model/id_token';
2621

2722
export interface SignInWithPasswordRequest {
2823
returnSecureToken?: boolean;

0 commit comments

Comments
 (0)