From 11e05d7b986948ef571a9cff8b7fb423bcb157ad Mon Sep 17 00:00:00 2001 From: Mrinal Wadhwa Date: Thu, 8 Nov 2018 16:05:13 -0800 Subject: [PATCH] test: add more tests for percent encoded chars in path and fragement --- did_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/did_test.go b/did_test.go index ab18dbc..3d04949 100644 --- a/did_test.go +++ b/did_test.go @@ -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) { @@ -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) {