mirror of
https://github.com/argoproj/argo-cd
synced 2026-05-24 09:50:08 +00:00
* chore: Upgrade Go module to v2 Signed-off-by: jannfis <jann@mistrust.net> * Restore import order Signed-off-by: jannfis <jann@mistrust.net> * fix knowntypes_normalizer codegen error Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> * fix codegen Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> * fix Procfile Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> Co-authored-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
31 lines
651 B
Go
31 lines
651 B
Go
package session
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
util "github.com/argoproj/argo-cd/v2/util/io"
|
|
"github.com/argoproj/argo-cd/v2/util/session"
|
|
)
|
|
|
|
func TestRateLimiter(t *testing.T) {
|
|
var closers []util.Closer
|
|
limiter := NewLoginRateLimiter(10)
|
|
for i := 0; i < 10; i++ {
|
|
closer, err := limiter()
|
|
assert.NoError(t, err)
|
|
closers = append(closers, closer)
|
|
}
|
|
// 11 request should fail
|
|
_, err := limiter()
|
|
assert.Equal(t, err, session.InvalidLoginErr)
|
|
|
|
if !assert.Equal(t, len(closers), 10) {
|
|
return
|
|
}
|
|
// complete one request
|
|
assert.NoError(t, closers[0].Close())
|
|
_, err = limiter()
|
|
assert.NoError(t, err)
|
|
}
|