Skip to content

Commit

Permalink
test: add more tests for percent encoded chars in path and fragement
Browse files Browse the repository at this point in the history
  • Loading branch information
mrinalwadhwa committed Nov 9, 2018
1 parent d86bfee commit 11e05d7
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions did_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,25 @@ func TestParse(t *testing.T) {
t.Errorf("error is nil")
}

_, err = Parse("did:a:123:456/%!*")
if err == nil {
t.Errorf("error is nil")
}

_, err = Parse("did:a:123:456/%!A")
if err == nil {
t.Errorf("error is nil")
}

_, err = Parse("did:a:123:456/%A!")
if err == nil {
t.Errorf("error is nil")
}

_, err = Parse("did:a:123:456/%A%")
if err == nil {
t.Errorf("error is nil")
}
})

t.Run("fails if path is empty but there is a slash", func(t *testing.T) {
Expand Down Expand Up @@ -401,6 +420,26 @@ func TestParse(t *testing.T) {
if err == nil {
t.Errorf("error is nil")
}

_, err = Parse("did:a:123:456#%!*")
if err == nil {
t.Errorf("error is nil")
}

_, err = Parse("did:a:123:456#%!A")
if err == nil {
t.Errorf("error is nil")
}

_, err = Parse("did:a:123:456#%A!")
if err == nil {
t.Errorf("error is nil")
}

_, err = Parse("did:a:123:456#%A%")
if err == nil {
t.Errorf("error is nil")
}
})

t.Run("fails if fragment has invalid char", func(t *testing.T) {
Expand Down

0 comments on commit 11e05d7

Please sign in to comment.