From 2783ea0d0f2e9aa481caf6373bd4b8a5a053d5ba Mon Sep 17 00:00:00 2001 From: Sandra Vrtikapa Date: Tue, 5 Jul 2022 12:43:45 -0400 Subject: [PATCH] chore: Add rotate log with DID operations CLI test Add new tests that will: 1. create did, rotate log, update did and check for updated did in rotated log 2. create, update, recover and deactivate did after log rotation and check existence in rotated log Closes #1391 Signed-off-by: Sandra Vrtikapa --- pkg/config/client/client.go | 4 +- test/bdd/features/did-orb.feature | 2 +- test/bdd/features/orb-cli.feature | 78 +++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/pkg/config/client/client.go b/pkg/config/client/client.go index b5613ed26..b7f7d1398 100644 --- a/pkg/config/client/client.go +++ b/pkg/config/client/client.go @@ -23,7 +23,7 @@ var logger = log.New("config-client") const ( defaultCacheSize = 100 - defaultCacheExpiration = time.Minute + defaultCacheExpiration = 5 * time.Second ) // Client implements retrieving and caching of config store parameters. @@ -37,7 +37,7 @@ type Client struct { unmarshal func([]byte, interface{}) error } -// New returns a new ActivityPub client. +// New returns a new config store client. func New(cfg storage.Store, opts ...Option) *Client { client := &Client{ configStore: cfg, diff --git a/test/bdd/features/did-orb.feature b/test/bdd/features/did-orb.feature index 6c11c596d..f0b3b158a 100644 --- a/test/bdd/features/did-orb.feature +++ b/test/bdd/features/did-orb.feature @@ -96,7 +96,7 @@ Feature: Then we wait 3 seconds - @vct_log_rotation_test + @vct_log_rotation_REST_test Scenario: various did doc operations Given the authorization bearer token for "POST" requests to path "/log" is set to "ADMIN_TOKEN" And the authorization bearer token for "POST" requests to path "/log-monitor" is set to "ADMIN_TOKEN" diff --git a/test/bdd/features/orb-cli.feature b/test/bdd/features/orb-cli.feature index b27eb3872..0b4c8908f 100644 --- a/test/bdd/features/orb-cli.feature +++ b/test/bdd/features/orb-cli.feature @@ -48,6 +48,84 @@ Feature: Using Orb CLI When Orb DID is deactivated through cli Then check cli deactivated DID + @orb_cli_did_rotate_log + Scenario: Rotate log, then update existing did followed by create new did and verify proofs in rotated VCT log + # domain2 server follows domain1 server + When user create "follower" activity with outbox-url "https://localhost:48426/services/orb/outbox" actor "https://orb.domain2.com/services/orb" to "https://orb.domain1.com/services/orb" action "Follow" + # domain1 invites domain2 to be a witness + When user create "witness" activity with outbox-url "https://localhost:48326/services/orb/outbox" actor "https://orb.domain1.com/services/orb" to "https://orb.domain2.com/services/orb" action "InviteWitness" + Then we wait 3 seconds + + # domain1 will start with 2020 VCT log + When orb-cli is executed with args 'log update --url https://localhost:48326/log --log "http://orb.vct:8077/maple2020" --tls-cacerts fixtures/keys/tls/ec-cacert.pem --auth-token ADMIN_TOKEN' + + # wait for config cache to expire + Then we wait 5 seconds + + When Create keys in kms + When Orb DID is created through cli + Then check cli created valid DID + And we wait 3 seconds + + When Orb DID is resolved through cli + Then the JSON path "didDocumentMetadata.versionId" of the response is saved to variable "anchorHash" + And we wait 3 seconds + + When orb-cli is executed with args 'vct verify --cas-url https://localhost:48326/cas --anchor ${anchorHash} --tls-cacerts fixtures/keys/tls/ec-cacert.pem --auth-token ADMIN_TOKEN --vct-auth-token=vctread' + Then the JSON path '#(domain=="http://orb.vct:8077/maple2020").found' of the boolean response equals "true" + + # domain1 will then rotate to 2022 VCT log + When orb-cli is executed with args 'log update --url https://localhost:48326/log --log "http://orb.vct:8077/maple2022" --tls-cacerts fixtures/keys/tls/ec-cacert.pem --auth-token ADMIN_TOKEN' + + # wait for config cache to expire + Then we wait 5 seconds + + When Orb DID is updated through cli + Then check cli updated DID + + When Orb DID is resolved through cli + Then the JSON path "didDocumentMetadata.versionId" of the response is saved to variable "anchorHash" + And we wait 3 seconds + + When orb-cli is executed with args 'vct verify --cas-url https://localhost:48326/cas --anchor ${anchorHash} --tls-cacerts fixtures/keys/tls/ec-cacert.pem --auth-token ADMIN_TOKEN --vct-auth-token=vctread' + Then the JSON path '#(domain=="http://orb.vct:8077/maple2022").found' of the boolean response equals "true" + + # now create new did after log rotation + + When Create keys in kms + When Orb DID is created through cli + Then check cli created valid DID + And we wait 3 seconds + + When Orb DID is resolved through cli + Then the JSON path "didDocumentMetadata.versionId" of the response is saved to variable "anchorHash" + And we wait 3 seconds + + When orb-cli is executed with args 'vct verify --cas-url https://localhost:48326/cas --anchor ${anchorHash} --tls-cacerts fixtures/keys/tls/ec-cacert.pem --auth-token ADMIN_TOKEN --vct-auth-token=vctread' + Then the JSON path '#(domain=="http://orb.vct:8077/maple2022").found' of the boolean response equals "true" + + When Orb DID is updated through cli + Then check cli updated DID + + When Orb DID is recovered through cli + Then check cli recovered DID + + When Orb DID is deactivated through cli + Then check cli deactivated DID + + When Orb DID is resolved through cli + Then the JSON path "didDocumentMetadata.versionId" of the response is saved to variable "anchorHash" + And we wait 3 seconds + + When orb-cli is executed with args 'vct verify --cas-url https://localhost:48326/cas --anchor ${anchorHash} --tls-cacerts fixtures/keys/tls/ec-cacert.pem --auth-token ADMIN_TOKEN --vct-auth-token=vctread' + Then the JSON path '#(domain=="http://orb.vct:8077/maple2022").found' of the boolean response equals "true" + + # re-set to 2020 VCT log for other tests + When orb-cli is executed with args 'log update --url https://localhost:48326/log --log "http://orb.vct:8077/maple2020" --tls-cacerts fixtures/keys/tls/ec-cacert.pem --auth-token ADMIN_TOKEN' + + # wait for config cache to expire + Then we wait 5 seconds + @orb_cli_activity Scenario: test follow and witness # domain1 server follows domain2 server