forked from openshift/osin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurivalidate_test.go
49 lines (40 loc) · 1.34 KB
/
urivalidate_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package osin
import (
"testing"
)
func TestURIValidate(t *testing.T) {
// V1
if err := ValidateUri("http://localhost:14000/appauth", "http://localhost:14000/appauth"); err != nil {
t.Errorf("V1: %s", err)
}
// V2
if err := ValidateUri("http://localhost:14000/appauth", "http://localhost:14000/app"); err == nil {
t.Error("V2 should have failed")
}
// V3
if err := ValidateUri("http://www.google.com/myapp", "http://www.google.com/myapp/interface/implementation"); err != nil {
t.Errorf("V3: %s", err)
}
// V4
if err := ValidateUri("http://www.google.com/myapp", "http://www2.google.com/myapp"); err == nil {
t.Error("V4 should have failed")
}
}
func TestURIListValidate(t *testing.T) {
// V1
if err := ValidateUriList("http://localhost:14000/appauth", "http://localhost:14000/appauth", ""); err != nil {
t.Errorf("V1: %s", err)
}
// V2
if err := ValidateUriList("http://localhost:14000/appauth", "http://localhost:14000/app", ""); err == nil {
t.Error("V2 should have failed")
}
// V3
if err := ValidateUriList("http://xxx:14000/appauth;http://localhost:14000/appauth", "http://localhost:14000/appauth", ";"); err != nil {
t.Errorf("V3: %s", err)
}
// V4
if err := ValidateUriList("http://xxx:14000/appauth;http://localhost:14000/appauth", "http://localhost:14000/app", ";"); err == nil {
t.Error("V4 should have failed")
}
}