Skip to content

Commit

Permalink
Add negative integration tests for testing
Browse files Browse the repository at this point in the history
versionTime and resourceVersionTime queries with an invalid date format.
  • Loading branch information
abdulla-ashurov committed Jun 19, 2023
1 parent b14c836 commit 931645f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
28 changes: 28 additions & 0 deletions tests/integration/rest/diddoc/query/version_time/negative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package versionTime
import (
"encoding/json"
"fmt"
"net/url"

testconstants "github.com/cheqd/did-resolver/tests/constants"
utils "github.com/cheqd/did-resolver/tests/integration/rest"
Expand Down Expand Up @@ -57,6 +58,33 @@ var _ = DescribeTable("Negative: Get DIDDoc with versionTime query", func(testCa
},
),

Entry(
"cannot get DIDDoc with not supported format of versionTime query parameter (not supported format)",
utils.NegativeTestCase{
DidURL: fmt.Sprintf(
"http://localhost:8080/1.0/identifiers/%s?versionTime=%s",
testconstants.SeveralVersionsDID,
url.QueryEscape("06/03/2023 09:36:54"),
),
ResolutionType: testconstants.DefaultResolutionType,
ExpectedResult: types.DidResolution{
Context: "",
ResolutionMetadata: types.ResolutionMetadata{
ContentType: types.DIDJSONLD,
ResolutionError: "invalidDidUrl",
DidProperties: types.DidProperties{
DidString: testconstants.SeveralVersionsDID,
MethodSpecificId: testconstants.SeveralVersionsDIDIdentifier,
Method: testconstants.ValidMethod,
},
},
Did: nil,
Metadata: types.ResolutionDidDocMetadata{},
},
ExpectedStatusCode: types.InvalidDidUrlHttpCode,
},
),

Entry(
"cannot get DIDDoc with an invalid versionTime query parameter",
utils.NegativeTestCase{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package resource_version_time_test
import (
"encoding/json"
"fmt"
"net/url"

testconstants "github.com/cheqd/did-resolver/tests/constants"
utils "github.com/cheqd/did-resolver/tests/integration/rest"
Expand Down Expand Up @@ -36,16 +37,16 @@ var _ = DescribeTable("Negative: Get Collection of Resources with resourceVersio
"cannot get collection of resources with not existent resourceVersionTime query parameter",
utils.NegativeTestCase{
DidURL: fmt.Sprintf(
"http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s",
"http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true",
testconstants.UUIDStyleTestnetDid,
"2023-03-06T09:36:56.56204903Z",
"2023-01-25T12:04:51Z",
),
ResolutionType: string(types.DIDJSONLD),
ExpectedResult: utils.DereferencingResult{
Context: "",
DereferencingMetadata: types.DereferencingMetadata{
ContentType: types.DIDJSONLD,
ResolutionError: "representationNotSupported",
ResolutionError: "notFound",
DidProperties: types.DidProperties{
DidString: testconstants.UUIDStyleTestnetDid,
MethodSpecificId: testconstants.UUIDStyleTestnetId,
Expand All @@ -55,7 +56,34 @@ var _ = DescribeTable("Negative: Get Collection of Resources with resourceVersio
ContentStream: nil,
Metadata: types.ResolutionDidDocMetadata{},
},
ExpectedStatusCode: errors.RepresentationNotSupportedHttpCode, // it should be notFound
ExpectedStatusCode: errors.NotFoundHttpCode, // it should be notFound
},
),

Entry(
"cannot get collection of resources with not supported format of resourceVersionTime query parameter",
utils.NegativeTestCase{
DidURL: fmt.Sprintf(
"http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true",
testconstants.UUIDStyleTestnetDid,
url.QueryEscape("06/03/2023 09:36:56"),
),
ResolutionType: string(types.DIDJSONLD),
ExpectedResult: utils.DereferencingResult{
Context: "",
DereferencingMetadata: types.DereferencingMetadata{
ContentType: types.DIDJSONLD,
ResolutionError: "invalidDidUrl",
DidProperties: types.DidProperties{
DidString: testconstants.UUIDStyleTestnetDid,
MethodSpecificId: testconstants.UUIDStyleTestnetId,
Method: testconstants.ValidMethod,
},
},
ContentStream: nil,
Metadata: types.ResolutionDidDocMetadata{},
},
ExpectedStatusCode: errors.InvalidDidUrlHttpCode,
},
),

Expand Down

0 comments on commit 931645f

Please sign in to comment.