Organize backend into product executable and shared Go modules
This commit is contained in:
1 parent
981e84a4b4
commit
f0720ec66b
382 files changed
+1944
-6989
No files matched your search
@@ -0,0 +1,52 @@
|
||||
package middleware
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestTokenConfigValidate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config TokenConfig
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "secure explicit TTLs",
|
||||
config: TokenConfig{
|
||||
Expiration: TokenExpiration{Account: 1, Refresh: 720},
|
||||
Length: 32,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "rejects legacy 24 hour access token",
|
||||
config: TokenConfig{
|
||||
Expiration: TokenExpiration{Account: 24, Refresh: 720},
|
||||
Length: 32,
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "rejects missing access TTL",
|
||||
config: TokenConfig{
|
||||
Expiration: TokenExpiration{Refresh: 720},
|
||||
Length: 32,
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "rejects weak refresh token",
|
||||
config: TokenConfig{
|
||||
Expiration: TokenExpiration{Account: 1, Refresh: 720},
|
||||
Length: 16,
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.config.Validate()
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Fatalf("Validate() error = %v, wantErr %t", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user