forked from TrueCloudLab/rclone
vendor: github.com/abbot/go-http-auth for #1802
This commit is contained in:
parent
5530662ccc
commit
2b6f7028a6
23 changed files with 1597 additions and 2 deletions
37
vendor/github.com/abbot/go-http-auth/misc_test.go
generated
vendored
Normal file
37
vendor/github.com/abbot/go-http-auth/misc_test.go
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestH(t *testing.T) {
|
||||
const hello = "Hello, world!"
|
||||
const hello_md5 = "6cd3556deb0da54bca060b4c39479839"
|
||||
h := H(hello)
|
||||
if h != hello_md5 {
|
||||
t.Fatal("Incorrect digest for test string:", h, "instead of", hello_md5)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsePairs(t *testing.T) {
|
||||
const header = `username="\test", realm="a \"quoted\" string", nonce="FRPnGdb8lvM1UHhi", uri="/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro", algorithm=MD5, response="fdcdd78e5b306ffed343d0ec3967f2e5", opaque="lEgVjogmIar2fg/t", qop=auth, nc=00000001, cnonce="e76b05db27a3b323"`
|
||||
|
||||
want := map[string]string{
|
||||
"username": "test",
|
||||
"realm": `a "quoted" string`,
|
||||
"nonce": "FRPnGdb8lvM1UHhi",
|
||||
"uri": "/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro",
|
||||
"algorithm": "MD5",
|
||||
"response": "fdcdd78e5b306ffed343d0ec3967f2e5",
|
||||
"opaque": "lEgVjogmIar2fg/t",
|
||||
"qop": "auth",
|
||||
"nc": "00000001",
|
||||
"cnonce": "e76b05db27a3b323",
|
||||
}
|
||||
got := ParsePairs(header)
|
||||
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("failed to correctly parse pairs, got %v, want %v\ndiff: %s", got, want)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue