feat: add ability to customize session duration of clients (#1641)

This commit is contained in:
Elias Schneider
2026-08-03 23:23:29 +02:00
committed by GitHub
parent 1238bf0f37
commit 5d43c4aaeb
28 changed files with 752 additions and 77 deletions
+29
View File
@@ -3,9 +3,38 @@ package dto
import (
"testing"
"github.com/gin-gonic/gin/binding"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestTokenDurationValidation(t *testing.T) {
type input struct {
Duration int64 `binding:"required,token_duration"`
}
for _, test := range []struct {
name string
value int64
wantErr bool
}{
{name: "omitted", wantErr: true},
{name: "below minimum", value: 0, wantErr: true},
{name: "minimum", value: 1},
{name: "custom duration", value: 90},
{name: "above maximum", value: 365*24*60 + 1, wantErr: true},
} {
t.Run(test.name, func(t *testing.T) {
err := binding.Validator.ValidateStruct(input{Duration: test.value})
if test.wantErr {
require.Error(t, err)
return
}
require.NoError(t, err)
})
}
}
func TestValidateUsername(t *testing.T) {
tests := []struct {
name string