forked from TrueCloudLab/certificates
Add test cases for uris with only the schema.
This commit is contained in:
parent
f6cbd9dc88
commit
d03c088ab7
1 changed files with 10 additions and 0 deletions
|
@ -99,6 +99,10 @@ func TestParse(t *testing.T) {
|
||||||
URL: &url.URL{Scheme: "yubikey", Opaque: "slot-id=9a"},
|
URL: &url.URL{Scheme: "yubikey", Opaque: "slot-id=9a"},
|
||||||
Values: url.Values{"slot-id": []string{"9a"}},
|
Values: url.Values{"slot-id": []string{"9a"}},
|
||||||
}, false},
|
}, false},
|
||||||
|
{"ok schema", args{"cloudkms:"}, &URI{
|
||||||
|
URL: &url.URL{Scheme: "cloudkms"},
|
||||||
|
Values: url.Values{},
|
||||||
|
}, false},
|
||||||
{"ok query", args{"yubikey:slot-id=9a;foo=bar?pin=123456&foo=bar"}, &URI{
|
{"ok query", args{"yubikey:slot-id=9a;foo=bar?pin=123456&foo=bar"}, &URI{
|
||||||
URL: &url.URL{Scheme: "yubikey", Opaque: "slot-id=9a;foo=bar", RawQuery: "pin=123456&foo=bar"},
|
URL: &url.URL{Scheme: "yubikey", Opaque: "slot-id=9a;foo=bar", RawQuery: "pin=123456&foo=bar"},
|
||||||
Values: url.Values{"slot-id": []string{"9a"}, "foo": []string{"bar"}},
|
Values: url.Values{"slot-id": []string{"9a"}, "foo": []string{"bar"}},
|
||||||
|
@ -115,6 +119,7 @@ func TestParse(t *testing.T) {
|
||||||
URL: &url.URL{Scheme: "file", Host: "tmp", Path: "/ca.cert"},
|
URL: &url.URL{Scheme: "file", Host: "tmp", Path: "/ca.cert"},
|
||||||
Values: url.Values{},
|
Values: url.Values{},
|
||||||
}, false},
|
}, false},
|
||||||
|
{"fail schema", args{"cloudkms"}, nil, true},
|
||||||
{"fail parse", args{"yubi%key:slot-id=9a"}, nil, true},
|
{"fail parse", args{"yubi%key:slot-id=9a"}, nil, true},
|
||||||
{"fail scheme", args{"yubikey"}, nil, true},
|
{"fail scheme", args{"yubikey"}, nil, true},
|
||||||
{"fail parse opaque", args{"yubikey:slot-id=%ZZ"}, nil, true},
|
{"fail parse opaque", args{"yubikey:slot-id=%ZZ"}, nil, true},
|
||||||
|
@ -148,12 +153,17 @@ func TestParseWithScheme(t *testing.T) {
|
||||||
URL: &url.URL{Scheme: "yubikey", Opaque: "slot-id=9a"},
|
URL: &url.URL{Scheme: "yubikey", Opaque: "slot-id=9a"},
|
||||||
Values: url.Values{"slot-id": []string{"9a"}},
|
Values: url.Values{"slot-id": []string{"9a"}},
|
||||||
}, false},
|
}, false},
|
||||||
|
{"ok schema", args{"cloudkms", "cloudkms:"}, &URI{
|
||||||
|
URL: &url.URL{Scheme: "cloudkms"},
|
||||||
|
Values: url.Values{},
|
||||||
|
}, false},
|
||||||
{"ok file", args{"file", "file:///tmp/ca.cert"}, &URI{
|
{"ok file", args{"file", "file:///tmp/ca.cert"}, &URI{
|
||||||
URL: &url.URL{Scheme: "file", Path: "/tmp/ca.cert"},
|
URL: &url.URL{Scheme: "file", Path: "/tmp/ca.cert"},
|
||||||
Values: url.Values{},
|
Values: url.Values{},
|
||||||
}, false},
|
}, false},
|
||||||
{"fail parse", args{"yubikey", "yubikey"}, nil, true},
|
{"fail parse", args{"yubikey", "yubikey"}, nil, true},
|
||||||
{"fail scheme", args{"yubikey", "awskms:slot-id=9a"}, nil, true},
|
{"fail scheme", args{"yubikey", "awskms:slot-id=9a"}, nil, true},
|
||||||
|
{"fail schema", args{"cloudkms", "cloudkms"}, nil, true},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue