mirror of
https://github.com/ZizzyDizzyMC/linx-server.git
synced 2026-01-23 02:14:33 +00:00
* Split and move auth into a separate package This change will make it easier to implement additional authentication methods, such as OpenID Connect. For now, only the existing "apikeys" authentication method is supported. * Use absolute site prefix to prevent redirect loop
24 lines
567 B
Go
24 lines
567 B
Go
package apikeys
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestCheckAuth(t *testing.T) {
|
|
authKeys := []string{
|
|
"vhvZ/PT1jeTbTAJ8JdoxddqFtebSxdVb0vwPlYO+4HM=",
|
|
"vFpNprT9wbHgwAubpvRxYCCpA2FQMAK6hFqPvAGrdZo=",
|
|
}
|
|
|
|
if r, err := CheckAuth(authKeys, ""); err != nil && r {
|
|
t.Fatal("Authorization passed for empty key")
|
|
}
|
|
|
|
if r, err := CheckAuth(authKeys, "thisisnotvalid"); err != nil && r {
|
|
t.Fatal("Authorization passed for invalid key")
|
|
}
|
|
|
|
if r, err := CheckAuth(authKeys, "haPVipRnGJ0QovA9nyqK"); err != nil && !r {
|
|
t.Fatal("Authorization failed for valid key")
|
|
}
|
|
}
|