generated from cheqd/.github
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add additional unit tests for resolver scenarios [DEV-2360] (#134)
* Add integration test data payloads. * Add integration test constants. * Create test runner for running integration tests. * Add positive integration tests for getting DIDDoc. * Add negative integration tests for getting DIDDoc. * Update go.mod and go.sum files. * Move DID document payloads to another folder. * Add did#fragment query payloads for integration tests. * Rename testCase member variable: - from "expectedDIDResolution" to "expectedDidResolution"; - from "receivedDIDResolution" to "receivedDidResolution"; - from "expectedDIDResolution" to "expectedDidResolution". * Add positive and integration tests for testing API that gets DID#fragment. * Fix golangci-lint mistakes. * Add build tag for building integration tests. * Fix golangci-lint mistakes. * Add DIDDoc version payloads for using in integration tests. * Add DIDDoc version metadata payloads for using in integration tests. * Add integration tests for testing resourceMetadata * Add integration tests for testing collection of resources API. * Add integration tests for testing resolver resource data request. * Refactor integration tests. * Add integration tests for testing get DIDDoc versions API. * Add integration tests for testing get DIDDoc version API. * Add integration tests for testing get DIDDoc version metadata API. * Add integration tests for testing how is working redirect when we try to get different API with old Indy style DID. * Refactor and update integration tests. * Remove an old integration tests. * Update integration tests. * Update integration tests for GitHub actions. * Update GitHub action test.yml file. * Add integration tests report file to .gitignore. * Update test.yml * DIDDoc version should return in resolution format. * Uncomment integration tests. * Add integration tests for testing accept header. * Refactor integration tests. * Add integration tests for testing accept-encoding header. * Rename folder name from "unit-tests" to "unit". * Update test.yml file. * Restructure integration tests folder structure. * Remove an unused ProcessDIDRequest method. * Move test from did_doc_service and resource_dereferencing_service to particular handlers. * Use constant variables instead of a header strings * Add unit tests for testing how works a redirect old 16/32 characters Indy style DIDs. * Re structure unit tests. * Add integration build flag for test_suite_test.go. * Refactor unit tests. * Add more unit tests for testing ledger services. * Add HTTP binding constants for using tests. * Correct the names of the integration test cases. * Add constant variables for using integration tests instead of magic strings. * Fix type mistakes. * Fix golangci-lint mistakes. * Update integration tests. * Update unit test runner command in GitHub actions.
- Loading branch information
1 parent
fa2de8a
commit bd4ea50
Showing
66 changed files
with
2,050 additions
and
1,675 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
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
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
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,66 @@ | ||
package testconstants | ||
|
||
import ( | ||
"crypto/sha256" | ||
"fmt" | ||
|
||
didTypes "github.com/cheqd/cheqd-node/api/v2/cheqd/did/v2" | ||
resourceTypes "github.com/cheqd/cheqd-node/api/v2/cheqd/resource/v2" | ||
) | ||
|
||
func generateVerificationMethod() didTypes.VerificationMethod { | ||
return didTypes.VerificationMethod{ | ||
Id: ExistentDid + "#key-1", | ||
VerificationMethodType: "JsonWebKey2020", | ||
Controller: ExistentDid, | ||
VerificationMaterial: ValidPubKeyJWK, | ||
} | ||
} | ||
|
||
func generateService() didTypes.Service { | ||
return didTypes.Service{ | ||
Id: ExistentDid + "#service-1", | ||
ServiceType: "DIDCommMessaging", | ||
ServiceEndpoint: []string{"http://example.com"}, | ||
} | ||
} | ||
|
||
func generateDIDDoc() didTypes.DidDoc { | ||
service := generateService() | ||
verificationMethod := generateVerificationMethod() | ||
|
||
return didTypes.DidDoc{ | ||
Id: ExistentDid, | ||
VerificationMethod: []*didTypes.VerificationMethod{&verificationMethod}, | ||
Service: []*didTypes.Service{&service}, | ||
} | ||
} | ||
|
||
func generateResource() resourceTypes.ResourceWithMetadata { | ||
data := []byte("{\"attr\":[\"name\",\"age\"]}") | ||
checksum := sha256.New().Sum(data) | ||
return resourceTypes.ResourceWithMetadata{ | ||
Resource: &resourceTypes.Resource{ | ||
Data: data, | ||
}, | ||
Metadata: &resourceTypes.Metadata{ | ||
CollectionId: ValidIdentifier, | ||
Id: ExistentResourceId, | ||
Name: "Existing Resource Name", | ||
ResourceType: "string", | ||
MediaType: "application/json", | ||
Checksum: fmt.Sprintf("%x", checksum), | ||
}, | ||
} | ||
} | ||
|
||
func generateMetadata() didTypes.Metadata { | ||
return didTypes.Metadata{VersionId: "test_version_id", Deactivated: false} | ||
} | ||
|
||
func generateChecksum(data []byte) string { | ||
h := sha256.New() | ||
h.Write(data) | ||
|
||
return fmt.Sprintf("%x", h.Sum(nil)) | ||
} |
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
Oops, something went wrong.