Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Add WebAuthnHarness to primtives
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed Sep 27, 2023
1 parent 74f72c1 commit e9f1361
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
8 changes: 4 additions & 4 deletions primitives/test/WebAuthn.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ pragma solidity ^0.8.12;

import "forge-std/Test.sol";
import {TestHelper} from "./utils/TestHelper.sol";
import {WebAuthn} from "../src/WebAuthn.sol";
import {WebAuthnHarness} from "./utils/WebAuthnHarness.sol";

/* solhint-disable func-name-mixedcase */

contract WebauthnTest is TestHelper {
constructor() TestHelper() {}

WebAuthn public webauthn;
WebAuthnHarness public webauthn;

function setUp() public {
webauthn = new WebAuthn();
webauthn = new WebAuthnHarness();
}

function test_verifySignature_ValidSignature() public {
Expand All @@ -29,7 +29,7 @@ contract WebauthnTest is TestHelper {
uint256[2] memory publicKey = getWebAuthnPublicKey();

// Act
bool verified = webauthn.verifySignature(
bool verified = webauthn.exposed_verifySignature(
authenticatorData,
authenticatorDataFlagMask,
clientData,
Expand Down
29 changes: 29 additions & 0 deletions primitives/test/utils/WebAuthnHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;

import {WebAuthn} from "../../src/WebAuthn.sol";

/** Helper contract to expose internal functions for testing */
contract WebAuthnHarness is WebAuthn {
constructor() WebAuthn() {}

function exposed_verifySignature(
bytes calldata authenticatorData,
bytes1 authenticatorDataFlagMask,
bytes calldata clientData,
bytes32 clientChallenge,
uint256 clientChallengeDataOffset,
uint256[2] calldata signature,
uint256[2] calldata publicKey
) external returns (bool) {
return verifySignature(
authenticatorData,
authenticatorDataFlagMask,
clientData,
clientChallenge,
clientChallengeDataOffset,
signature,
publicKey
);
}
}

0 comments on commit e9f1361

Please sign in to comment.