20 lines
343 B
Go
20 lines
343 B
Go
package auth
|
|
|
|
import "testing"
|
|
|
|
func TestGenerateAndHashAPIKey(t *testing.T) {
|
|
key, err := GenerateAPIKey()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := ValidateAPIKeyFormat(key); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if HashAPIKey(key) == "" {
|
|
t.Fatal("empty hash")
|
|
}
|
|
if HashAPIKey(key) != HashAPIKey(key) {
|
|
t.Fatal("hash not stable")
|
|
}
|
|
}
|