-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Asra Ali <[email protected]>
- Loading branch information
Showing
8 changed files
with
98 additions
and
41 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -41,6 +41,29 @@ func TestAddKey(t *testing.T) { | |
} | ||
} | ||
|
||
func TestValidKey(t *testing.T) { | ||
root := NewRoot() | ||
publicKey := FulcioVerificationKey("[email protected]", "https://accounts.google.com") | ||
if !root.AddKey(publicKey) { | ||
t.Errorf("Adding new key failed") | ||
} | ||
role := &Role{KeyIDs: []string{}, Threshold: 1} | ||
role.AddKeysWithThreshold([]*Key{publicKey}, 2) | ||
root.Roles["root"] = role | ||
|
||
if _, ok := root.Keys[publicKey.ID()]; !ok { | ||
t.Errorf("Error adding public key") | ||
} | ||
if _, err := root.ValidKey(publicKey, "root"); err != nil { | ||
t.Errorf("Error checking key validit %s", err) | ||
} | ||
// Now change issuer, and expect error. | ||
publicKey = FulcioVerificationKey("[email protected]", "") | ||
if _, err := root.ValidKey(publicKey, "root"); err == nil { | ||
t.Errorf("Expected invalid key with mismatching issuer") | ||
} | ||
} | ||
|
||
func TestRootRole(t *testing.T) { | ||
root := NewRoot() | ||
publicKey := FulcioVerificationKey("[email protected]", "") | ||
|
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