2015-10-11 21:37:36 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCheckAuth(t *testing.T) {
|
|
|
|
authKeys := []string{
|
|
|
|
"vhvZ/PT1jeTbTAJ8JdoxddqFtebSxdVb0vwPlYO+4HM=",
|
|
|
|
"vFpNprT9wbHgwAubpvRxYCCpA2FQMAK6hFqPvAGrdZo=",
|
|
|
|
}
|
|
|
|
|
2015-10-14 16:13:29 -04:00
|
|
|
if r, err := checkAuth(authKeys, ""); err != nil && r {
|
2015-10-11 21:37:36 -04:00
|
|
|
t.Fatal("Authorization passed for empty key")
|
|
|
|
}
|
|
|
|
|
2015-10-14 16:13:29 -04:00
|
|
|
if r, err := checkAuth(authKeys, "thisisnotvalid"); err != nil && r {
|
2015-10-11 21:37:36 -04:00
|
|
|
t.Fatal("Authorization passed for invalid key")
|
|
|
|
}
|
|
|
|
|
2015-10-14 16:13:29 -04:00
|
|
|
if r, err := checkAuth(authKeys, "haPVipRnGJ0QovA9nyqK"); err != nil && !r {
|
2015-10-11 21:37:36 -04:00
|
|
|
t.Fatal("Authorization failed for valid key")
|
|
|
|
}
|
|
|
|
}
|