23 lines
429 B
Go
23 lines
429 B
Go
|
|
package auth
|
||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestGenerateState_Length(t *testing.T) {
|
||
|
|
s, err := GenerateState()
|
||
|
|
if err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
// 32 random bytes → 43 base64url chars (no padding)
|
||
|
|
if len(s) < 32 {
|
||
|
|
t.Errorf("state too short: %d chars", len(s))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestGenerateState_Unique(t *testing.T) {
|
||
|
|
a, _ := GenerateState()
|
||
|
|
b, _ := GenerateState()
|
||
|
|
if a == b {
|
||
|
|
t.Error("two calls returned the same state")
|
||
|
|
}
|
||
|
|
}
|