Skip to content

Commit

Permalink
fixup! chore : ei-2938 - extend unit test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
andyantrim committed Jun 6, 2024
1 parent f516b2c commit 8625ca7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 0 additions & 6 deletions pkg/advancedapi/advancedApi.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,6 @@ func createProof(
) (*register.Issuer, *proof.Proof, error) {
for _, v := range subjectDoc.PublicKeys {
if v.PublicKeyBase58 == subjectKeyPair.PublicKeyBase58 {
if v.Revoked {
return nil, nil, fmt.Errorf("subject public key is revoked")
}
issuer, err := register.NewIssuer(subjectDoc.ID, v.ID)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -545,9 +542,6 @@ func ValidateDocumentProof(document *register.RegisterDocument) error {
publicKeyBytes := base58.DecodeAlphabet(v.PublicKeyBase58, base58.BTCAlphabet)
did, _ := identity.MakeIdentifier(publicKeyBytes)
if did == document.ID {
if v.Revoked {
return fmt.Errorf("subject public key is revoked")
}
docProof := &proof.Proof{
IssuerDid: document.ID,
IssuerName: v.ID,
Expand Down
8 changes: 4 additions & 4 deletions pkg/advancedapi/advancedApi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Test_can_get_generic_delegation_proof(t *testing.T) {
assert.DeepEqual(t, proof.Content, []byte(""))
}

func Test_cannot_get_delegation_proof(t *testing.T) {
func Test_can_get_delegation_proof_with_revoked_key(t *testing.T) {
ctx := context.TODO()
subjectDoc, subjectIssuer := test.HelperGetRegisterDocumentFromSecret(test.ValidKeyPairPlop, "#name", identity.User)
delegatingIssuer, err := register.NewIssuer("did:iotics:iotXarXAbViugciWyuFmwRTbNoB6y8Wievfn", "#user-0")
Expand All @@ -81,7 +81,7 @@ func Test_cannot_get_delegation_proof(t *testing.T) {
assert.NilError(t, err)

_, _, err = advancedapi.CreateDelegationProof(delegatingIssuer, subjectDoc, test.ValidKeyPairPlop)
assert.ErrorContains(t, err, "key is revoked")
assert.NilError(t, err)
}

func Test_can_get_document_if_exists(t *testing.T) {
Expand Down Expand Up @@ -540,7 +540,7 @@ func Test_can_validate_document_proof(t *testing.T) {
assert.NilError(t, err)
}

func Test_cannot_validate_document_proof(t *testing.T) {
func Test_can_validate_document_proof_with_revoked_key(t *testing.T) {
ctx := context.TODO()
resolver := test.NewInMemoryResolver()
twinID, _, err := advancedapi.CreateNewIdentityAndRegister(ctx, resolver, identity.Twin, test.ValidKeyPairPlop, "#ExistingId", false)
Expand All @@ -561,7 +561,7 @@ func Test_cannot_validate_document_proof(t *testing.T) {
assert.NilError(t, err)

err = advancedapi.ValidateDocumentProof(doc)
assert.ErrorContains(t, err, "key is revoked")
assert.NilError(t, err)
}

func Test_can_create_seed(t *testing.T) {
Expand Down

0 comments on commit 8625ca7

Please sign in to comment.