2020-08-14 09:42:45 +02:00
|
|
|
package apikeys
|
2015-10-12 03:37:36 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCheckAuth(t *testing.T) {
|
|
|
|
authKeys := []string{
|
|
|
|
"vhvZ/PT1jeTbTAJ8JdoxddqFtebSxdVb0vwPlYO+4HM=",
|
|
|
|
"vFpNprT9wbHgwAubpvRxYCCpA2FQMAK6hFqPvAGrdZo=",
|
|
|
|
}
|
|
|
|
|
2020-08-14 09:42:45 +02:00
|
|
|
if r, err := CheckAuth(authKeys, ""); err != nil && r {
|
2015-10-12 03:37:36 +02:00
|
|
|
t.Fatal("Authorization passed for empty key")
|
|
|
|
}
|
|
|
|
|
2020-08-14 09:42:45 +02:00
|
|
|
if r, err := CheckAuth(authKeys, "thisisnotvalid"); err != nil && r {
|
2015-10-12 03:37:36 +02:00
|
|
|
t.Fatal("Authorization passed for invalid key")
|
|
|
|
}
|
|
|
|
|
2020-08-14 09:42:45 +02:00
|
|
|
if r, err := CheckAuth(authKeys, "haPVipRnGJ0QovA9nyqK"); err != nil && !r {
|
2015-10-12 03:37:36 +02:00
|
|
|
t.Fatal("Authorization failed for valid key")
|
|
|
|
}
|
|
|
|
}
|