2021-12-25 02:16:58 +01:00
|
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Test stubs for now
|
|
|
|
|
|
|
|
func TestAuthNewTokenSuccess(t *testing.T) {
|
|
|
|
t.Fatalf("Test me: New token passes. Different scopes etc.")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAuthNewTokenFail(t *testing.T) {
|
|
|
|
t.Fatalf("Test me: New token fails (error generating random string? others?)")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAuthScopeValid(t *testing.T) {
|
2022-06-08 00:41:32 +02:00
|
|
|
fullAuthToken := AuthToken{Scope: "*"}
|
|
|
|
if !fullAuthToken.ScopeValid("*") {
|
|
|
|
t.Fatalf("Expected * to be a valid scope for *")
|
|
|
|
}
|
|
|
|
if !fullAuthToken.ScopeValid("banana") {
|
|
|
|
t.Fatalf("Expected * to be a valid scope for banana")
|
|
|
|
}
|
|
|
|
|
|
|
|
bananaAuthToken := AuthToken{Scope: "banana"}
|
|
|
|
if !bananaAuthToken.ScopeValid("banana") {
|
|
|
|
t.Fatalf("Expected banana to be a valid scope for banana")
|
|
|
|
}
|
2021-12-25 02:16:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAuthScopeInvalid(t *testing.T) {
|
2022-06-08 00:41:32 +02:00
|
|
|
bananaAuthToken := AuthToken{Scope: "banana"}
|
|
|
|
|
|
|
|
if bananaAuthToken.ScopeValid("*") {
|
|
|
|
t.Fatalf("Expected banana to be an invalid scope for *")
|
|
|
|
}
|
2021-12-25 02:16:58 +01:00
|
|
|
}
|