forked from emmaguo13/zk-blind
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
4 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
58 changes: 58 additions & 0 deletions
58
packages/contracts/test/JwtRegistry/JwtRegistry_disableAzp.t.sol
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
import "forge-std/Test.sol"; | ||
import "forge-std/console.sol"; | ||
// import {EmailAuth, EmailAuthMsg} from "../../../src/EmailAuth.sol"; | ||
// import {RecoveryController} from "../../helpers/RecoveryController.sol"; | ||
// import {StructHelper} from "../../helpers/StructHelper.sol"; | ||
// import {SimpleWallet} from "../../helpers/SimpleWallet.sol"; | ||
// import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import "@zk-email/contracts/DKIMRegistry.sol"; | ||
import {JwtRegistryTestBase} from "./JwtRegistryBase.t.sol"; | ||
|
||
contract JwtRegistryTest_disableAzp is JwtRegistryTestBase { | ||
constructor() {} | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
} | ||
|
||
function testRevert_disableAzp_invalidDomainNameFormat() public { | ||
string memory invalidDomainName = "12345|https://example.com"; | ||
vm.expectRevert(bytes("Invalid kid|iss|azp strings")); | ||
jwtRegistry.disableAzp(invalidDomainName); | ||
} | ||
|
||
function testRevert_disableAzp_tooManyParts() public { | ||
string | ||
memory invalidDomainName = "12345|https://example.com|client-id-12345|extra"; | ||
vm.expectRevert(bytes("Invalid kid|iss|azp strings")); | ||
jwtRegistry.disableAzp(invalidDomainName); | ||
} | ||
|
||
function testRevert_disableAzp_emptyString() public { | ||
string memory invalidDomainName = ""; | ||
vm.expectRevert(bytes("Invalid kid|iss|azp strings")); | ||
jwtRegistry.disableAzp(invalidDomainName); | ||
} | ||
|
||
function test_disableAzp() public { | ||
string memory domainName = "12345|https://example.com|client-id-12345"; | ||
|
||
// Verify that client-id-12345 is whitelisted | ||
assertTrue( | ||
jwtRegistry.whitelistedClients("client-id-12345"), | ||
"Client should be whitelisted initially" | ||
); | ||
|
||
// Call disableAzp | ||
jwtRegistry.disableAzp(domainName); | ||
|
||
// Verify that client-id-12345 is no longer whitelisted | ||
assertFalse( | ||
jwtRegistry.whitelistedClients("client-id-12345"), | ||
"Client should not be whitelisted after disableAzp" | ||
); | ||
} | ||
} |
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