Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
policy
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaia-X
Trust Services API
policy
Commits
bf2d98d8
Commit
bf2d98d8
authored
2 years ago
by
Yordan Kinkov
Browse files
Options
Downloads
Patches
Plain Diff
Rename extension functions in tests
parent
18d00f49
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
internal/regofunc/did_web_test.go
+15
-15
15 additions, 15 deletions
internal/regofunc/did_web_test.go
with
15 additions
and
15 deletions
internal/regofunc/did_web_test.go
+
15
−
15
View file @
bf2d98d8
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
"gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/policy/internal/regofunc"
"gitlab.com/gaia-x/data-infrastructure-federation-services/tsa/policy/internal/regofunc"
)
)
func
TestToURLFunc
(
t
*
testing
.
T
)
{
func
Test
DID
ToURLFunc
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
// test input
// test input
name
string
name
string
...
@@ -21,32 +21,32 @@ func TestToURLFunc(t *testing.T) {
...
@@ -21,32 +21,32 @@ func TestToURLFunc(t *testing.T) {
}{
}{
{
{
name
:
"DID is empty"
,
name
:
"DID is empty"
,
regoQuery
:
`
url_from_did
("")`
,
regoQuery
:
`
did_to_url
("")`
,
errText
:
"DID cannot be empty"
,
errText
:
"DID cannot be empty"
,
},
},
{
{
name
:
"invalid DID"
,
name
:
"invalid DID"
,
regoQuery
:
`
url_from_did
("invalid-did")`
,
regoQuery
:
`
did_to_url
("invalid-did")`
,
errText
:
"invalid DID, host is not found"
,
errText
:
"invalid DID, host is not found"
,
},
},
{
{
name
:
"invalid DID Method"
,
name
:
"invalid DID Method"
,
regoQuery
:
`
url_from_did
("did:sov:123456qwerty")`
,
regoQuery
:
`
did_to_url
("did:sov:123456qwerty")`
,
errText
:
"invalid DID, method is unknown"
,
errText
:
"invalid DID, method is unknown"
,
},
},
{
{
name
:
"transformation success with DID containing domain only"
,
name
:
"transformation success with DID containing domain only"
,
regoQuery
:
`
url_from_did
("did:web:w3c-ccg.github.io")`
,
regoQuery
:
`
did_to_url
("did:web:w3c-ccg.github.io")`
,
res
:
"
\"
https://w3c-ccg.github.io/.well-known/did.json
\"
"
,
res
:
"
\"
https://w3c-ccg.github.io/.well-known/did.json
\"
"
,
},
},
{
{
name
:
"transformation success with DID containing domain and path"
,
name
:
"transformation success with DID containing domain and path"
,
regoQuery
:
`
url_from_did
("did:web:w3c-ccg.github.io:user:alice")`
,
regoQuery
:
`
did_to_url
("did:web:w3c-ccg.github.io:user:alice")`
,
res
:
"
\"
https://w3c-ccg.github.io/user/alice/did.json
\"
"
,
res
:
"
\"
https://w3c-ccg.github.io/user/alice/did.json
\"
"
,
},
},
{
{
name
:
"transformation success with DID containing network port"
,
name
:
"transformation success with DID containing network port"
,
regoQuery
:
`
url_from_did
("did:web:example.com%3A3000:user:alice")`
,
regoQuery
:
`
did_to_url
("did:web:example.com%3A3000:user:alice")`
,
res
:
"
\"
https://example.com:3000/user/alice/did.json
\"
"
,
res
:
"
\"
https://example.com:3000/user/alice/did.json
\"
"
,
},
},
}
}
...
@@ -73,7 +73,7 @@ func TestToURLFunc(t *testing.T) {
...
@@ -73,7 +73,7 @@ func TestToURLFunc(t *testing.T) {
}
}
}
}
func
Test
FromURL
Func
(
t
*
testing
.
T
)
{
func
Test
URLToDID
Func
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
// test input
// test input
name
string
name
string
...
@@ -84,37 +84,37 @@ func TestFromURLFunc(t *testing.T) {
...
@@ -84,37 +84,37 @@ func TestFromURLFunc(t *testing.T) {
}{
}{
{
{
name
:
"empty URL"
,
name
:
"empty URL"
,
regoQuery
:
`
did_from_url
("")`
,
regoQuery
:
`
url_to_did
("")`
,
errText
:
"URL cannot be empty"
,
errText
:
"URL cannot be empty"
,
},
},
{
{
name
:
"URL containing special characters"
,
name
:
"URL containing special characters"
,
regoQuery
:
`
did_from_url
("example.com\nH1234")`
,
regoQuery
:
`
url_to_did
("example.com\nH1234")`
,
errText
:
"cannot parse URL"
,
errText
:
"cannot parse URL"
,
},
},
{
{
name
:
"URL does not contain secure protocol (https)"
,
name
:
"URL does not contain secure protocol (https)"
,
regoQuery
:
`
did_from_url
("example.com")`
,
regoQuery
:
`
url_to_did
("example.com")`
,
errText
:
"invalid URL for did:web method"
,
errText
:
"invalid URL for did:web method"
,
},
},
{
{
name
:
"URL does not contain valid domain"
,
name
:
"URL does not contain valid domain"
,
regoQuery
:
`
did_from_url
("https://")`
,
regoQuery
:
`
url_to_did
("https://")`
,
errText
:
"invalid URL for did:web method"
,
errText
:
"invalid URL for did:web method"
,
},
},
{
{
name
:
"transformation success with URL containing domain only"
,
name
:
"transformation success with URL containing domain only"
,
regoQuery
:
`
did_from_url
("https://w3c-ccg.github.io/.well-known/did.json")`
,
regoQuery
:
`
url_to_did
("https://w3c-ccg.github.io/.well-known/did.json")`
,
res
:
"
\"
did:web:w3c-ccg.github.io
\"
"
,
res
:
"
\"
did:web:w3c-ccg.github.io
\"
"
,
},
},
{
{
name
:
"transformation success with URL containing domain with path"
,
name
:
"transformation success with URL containing domain with path"
,
regoQuery
:
`
did_from_url
("https://w3c-ccg.github.io/user/alice/did.json")`
,
regoQuery
:
`
url_to_did
("https://w3c-ccg.github.io/user/alice/did.json")`
,
res
:
"
\"
did:web:w3c-ccg.github.io:user:alice
\"
"
,
res
:
"
\"
did:web:w3c-ccg.github.io:user:alice
\"
"
,
},
},
{
{
name
:
"transformation success with URL containing network port"
,
name
:
"transformation success with URL containing network port"
,
regoQuery
:
`
did_from_url
("https://example.com:3000/user/alice/did.json")`
,
regoQuery
:
`
url_to_did
("https://example.com:3000/user/alice/did.json")`
,
res
:
"
\"
did:web:example.com%3A3000:user:alice
\"
"
,
res
:
"
\"
did:web:example.com%3A3000:user:alice
\"
"
,
},
},
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment