refactor: move fcm to gcloud folder
This commit is contained in:
51
src/libs/gcloud/verifyFcmToken.spec.ts
Normal file
51
src/libs/gcloud/verifyFcmToken.spec.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
|
||||
import { server } from "~/mocks";
|
||||
|
||||
import type { AdminSdkCredentials } from "./getGoogleAuthToken";
|
||||
import { verifyFcmToken } from "./verifyFcmToken";
|
||||
|
||||
server.listen();
|
||||
|
||||
const FAKE_ADMIN_SDK_JSON: AdminSdkCredentials = {
|
||||
type: "service_account",
|
||||
projectId: "test-26g38",
|
||||
privateKeyId: "privateKeyId",
|
||||
privateKey: "privateKey",
|
||||
clientEmail: "test@test.com",
|
||||
clientID: "clientId",
|
||||
authURI: "https://accounts.google.com/o/oauth2/auth",
|
||||
tokenURI: "https://oauth2.googleapis.com/token",
|
||||
authProviderX509CertUrl: "https://www.googleapis.com/oauth2/v1/certs",
|
||||
clientX509CertUrl:
|
||||
"https://www.googleapis.com/robot/v1/metadata/x509/test%40test.com",
|
||||
universeDomain: "aniplay.com",
|
||||
};
|
||||
|
||||
describe("verifyFcmToken", () => {
|
||||
// it("valid token, returns true", async () => {
|
||||
// const token =
|
||||
// "7v8sy43aq0re4r8xe7rmr0cn1fsmh6phehnfla2pa73z899zmhyarivmkt4sj6pyv0py43u6p2sim6wz2vg9ypjp9rug1keoth7f6ll3gdvas4q020u3ah51r6bjgn51j6bd92ztmtof3ljpcm8q31njvndy65enm68";
|
||||
// const res = await verifyFcmToken(token, FAKE_ADMIN_SDK_JSON);
|
||||
|
||||
// expect(res).toBeTrue();
|
||||
// });
|
||||
|
||||
it("invalid token, returns false", async () => {
|
||||
const token = "abc123";
|
||||
const res = await verifyFcmToken(token, FAKE_ADMIN_SDK_JSON);
|
||||
|
||||
expect(res).toBeFalse();
|
||||
});
|
||||
|
||||
it("invalid ADMIN_SDK_JSON, returns false", async () => {
|
||||
const token =
|
||||
"7v8sy43aq0re4r8xe7rmr0cn1fsmh6phehnfla2pa73z899zmhyarivmkt4sj6pyv0py43u6p2sim6wz2vg9ypjp9rug1keoth7f6ll3gdvas4q020u3ah51r6bjgn51j6bd92ztmtof3ljpcm8q31njvndy65enm68";
|
||||
const res = await verifyFcmToken(token, {
|
||||
...FAKE_ADMIN_SDK_JSON,
|
||||
clientEmail: "",
|
||||
});
|
||||
|
||||
expect(res).toBeFalse();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user