Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
catching more bad params
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanwietsma committed Dec 1, 2014
1 parent 0b40af9 commit 034fc2f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,22 @@ func TestParseBadUri(t *testing.T) {
if err := k.FromURI(uri); err == nil {
t.Errorf("Parse URI should have failed: %v", k)
}

uri = "otpauth://totp/label?secret=MFRGGZDFMZTWQ2LK&issuer=theIssuer&algo=SHA1&digits=X"
if err := k.FromURI(uri); err == nil {
t.Errorf("Parse URI should have failed: %v", k)
}

//uri = "otpauth://totp/label?secret=MFRGGZDFMZTWQ2LK&issuer=theIssuer&algo=SHA1&period=X"
//if err := k.FromURI(uri); err == nil {
// t.Errorf("Parse URI should have failed: %v", k)
//}

uri = "otpauth://hotp/label?secret=MFRGGZDFMZTWQ2LK&issuer=theIssuer&algo=SHA1&counter=X"
if err := k.FromURI(uri); err == nil {
t.Errorf("Parse URI should have failed: %v", k)
}

}

func TestParseAlgo(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (k *Key) FromURI(uri string) error {
if u.Path == "" {
return errors.New("missing label")
}
(*k).Label = u.Path[1 : len(u.Path)-1]
(*k).Label = u.Path[1:len(u.Path)]

params := u.Query()
(*k).Secret = params.Get("secret")
Expand Down

0 comments on commit 034fc2f

Please sign in to comment.