Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
niftyvictor committed Feb 4, 2025
1 parent 5221d4b commit 11f52c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
10 changes: 4 additions & 6 deletions lib/ts/recipe/webauthn/recipeImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,20 +315,18 @@ export default function getRecipeInterface(
getUserFromRecoverAccountToken: async function ({ token, tenantId, userContext }) {
return await querier.sendGetRequest(
new NormalisedURLPath(
`/${
tenantId === undefined ? DEFAULT_TENANT_ID : tenantId
}/recipe/webauthn/user/recover/token/${token}`
`/${tenantId === undefined ? DEFAULT_TENANT_ID : tenantId}/recipe/webauthn/user/recover/token`
),
{},
{ token },
userContext
);
},

removeCredential: async function ({ webauthnCredentialId, recipeUserId, userContext }) {
return await querier.sendDeleteRequest(
new NormalisedURLPath(`/recipe/webauthn/user/${recipeUserId}/credential/${webauthnCredentialId}`),
{},
new NormalisedURLPath(`/recipe/webauthn/user/credential/remove`),
{},
{ recipeUserId, webauthnCredentialId },
userContext
);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/ts/recipe/webauthn/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export type RecipeInterface = {
}): Promise<{
status: "OK";
credentials: {
id: string;
webauthnCredentialId: string;
relyingPartyId: string;
createdAt: number;
}[];
Expand Down
21 changes: 6 additions & 15 deletions test/webauthn/apis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ describe(`apisFunctions: ${printPath("[test/webauthn/apis.test.js]")}`, function

assert(typeof signInOptionsResponse.challenge === "string");
assert(Number.isInteger(signInOptionsResponse.timeout));
assert(Number.isInteger(signInOptionsResponse.createdAt));
assert(Number.isInteger(signInOptionsResponse.expiresAt));
assert(signInOptionsResponse.userVerification === "preferred");

const generatedOptions = await SuperTokens.getInstanceOrThrowError().recipeModules[0].recipeInterfaceImpl.getGeneratedOptions(
Expand Down Expand Up @@ -323,6 +325,8 @@ describe(`apisFunctions: ${printPath("[test/webauthn/apis.test.js]")}`, function
assert(typeof signInOptionsResponse.webauthnGeneratedOptionsId === "string");
assert(typeof signInOptionsResponse.challenge === "string");
assert(Number.isInteger(signInOptionsResponse.timeout));
assert(Number.isInteger(signInOptionsResponse.createdAt));
assert(Number.isInteger(signInOptionsResponse.expiresAt));
assert(signInOptionsResponse.userVerification === "preferred");

const generatedOptions = await SuperTokens.getInstanceOrThrowError().recipeModules[0].recipeInterfaceImpl.getGeneratedOptions(
Expand All @@ -331,7 +335,6 @@ describe(`apisFunctions: ${printPath("[test/webauthn/apis.test.js]")}`, function
userContext: {},
}
);
console.log("generatedOptions", generatedOptions);

assert(generatedOptions.relyingPartyId === "testId.com");
assert(generatedOptions.origin === "testOrigin.com");
Expand Down Expand Up @@ -500,6 +503,7 @@ describe(`apisFunctions: ${printPath("[test/webauthn/apis.test.js]")}`, function
}
})
);
console.log("registerOptionsResponse", registerOptionsResponse);
assert(registerOptionsResponse.status === "OK");

let signInOptionsResponse = await new Promise((resolve, reject) =>
Expand All @@ -516,6 +520,7 @@ describe(`apisFunctions: ${printPath("[test/webauthn/apis.test.js]")}`, function
}
})
);
console.log("signInOptionsResponse", signInOptionsResponse);
assert(signInOptionsResponse.status === "OK");

const { createAndAssertCredential } = await getWebauthnLib();
Expand Down Expand Up @@ -549,20 +554,6 @@ describe(`apisFunctions: ${printPath("[test/webauthn/apis.test.js]")}`, function

assert(signUpResponse.status === "OK");

// todo remove this when the core is implemented
// mock the core to return the user
nock("http://localhost:8080/", { allowUnmocked: true })
.get("/public/users/by-accountinfo")
.query({ email, doUnionOfAccountInfo: true })
.reply(200, (uri, body) => {
return { status: "OK", users: [signUpResponse.user] };
})
.get("/user/id")
.query({ userId: signUpResponse.user.id })
.reply(200, (uri, body) => {
return { status: "OK", user: signUpResponse.user };
});

let signInResponse = await new Promise((resolve, reject) =>
request(app)
.post("/auth/webauthn/signin")
Expand Down

0 comments on commit 11f52c0

Please sign in to comment.