-
Notifications
You must be signed in to change notification settings - Fork 13
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 #133 from codeforjapan/yash/e2e-part2
- Loading branch information
Showing
6 changed files
with
162 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsNumber } from 'class-validator' | ||
import { IsInt, Min, Max } from 'class-validator' | ||
|
||
export class LoginNormalUserRequestDto { | ||
@ApiProperty() | ||
@IsNumber() | ||
@IsInt() | ||
@Min(0) | ||
@Max(47) | ||
prefecture: number | ||
} |
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 |
---|---|---|
@@ -1,15 +1,54 @@ | ||
import * as request from 'supertest' | ||
|
||
// TODO @yashmurty : WIP. | ||
export async function generateFirebaseDefaultToken(customToken: string, firebaseWebAPIKey: string) { | ||
await request(`https://identitytoolkit.googleapis.com/`) | ||
.post(`/v1/accounts:signInWithCustomToken?key=${firebaseWebAPIKey}`) | ||
.send({ | ||
token: customToken, | ||
returnSecureToken: true, | ||
import axios from 'axios' | ||
import * as firebaseAdmin from 'firebase-admin' | ||
|
||
/** | ||
* Generate firebase default token. Uses the custom token generated via | ||
* Firebase Admin SDK and returns firebase idToken. | ||
* @param customToken | ||
* @param firebaseWebAPIKey | ||
*/ | ||
export async function generateFirebaseDefaultToken( | ||
customToken: string, | ||
firebaseWebAPIKey: string | ||
): Promise<string> { | ||
let firebaseDefaultToken: string | ||
|
||
await axios | ||
.post( | ||
`https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key= | ||
${firebaseWebAPIKey}`, | ||
{ | ||
token: customToken, | ||
returnSecureToken: true, | ||
} | ||
) | ||
.then(function(response) { | ||
firebaseDefaultToken = response.data.idToken | ||
}) | ||
.set('Content-Type', 'application/json') | ||
.expect((response) => { | ||
console.log(response.body) | ||
.catch(function(error) { | ||
console.log(error.response.data.error) | ||
throw error | ||
}) | ||
|
||
return firebaseDefaultToken | ||
} | ||
|
||
/** | ||
* Delete the test user from firebase auth and firestore. | ||
* @param testUIDNormalUser | ||
*/ | ||
export async function deleteFirebaseTestUser(testUIDNormalUser: string): Promise<void> { | ||
await firebaseAdmin.auth().deleteUser(testUIDNormalUser) | ||
await firebaseAdmin | ||
.firestore() | ||
.collection('users') | ||
.doc(testUIDNormalUser) | ||
.collection('profile') | ||
.doc(testUIDNormalUser) | ||
.delete() | ||
await firebaseAdmin | ||
.firestore() | ||
.collection('users') | ||
.doc(testUIDNormalUser) | ||
.delete() | ||
} |