mirror of
https://github.com/minio/minio.git
synced 2025-11-22 02:35:30 -05:00
Honor DurationSeconds properly for WebIdentity (#8581)
Also cleanup code to add various constants for verbatim strings across the code base. Fixes #8482
This commit is contained in:
committed by
Nitish Tiwari
parent
c7844fb1fb
commit
b21835f195
@@ -16,7 +16,43 @@
|
||||
|
||||
package auth
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestExpToInt64(t *testing.T) {
|
||||
testCases := []struct {
|
||||
exp interface{}
|
||||
expectedFailure bool
|
||||
}{
|
||||
{"", true},
|
||||
{"-1", true},
|
||||
{"1574812326", false},
|
||||
{1574812326, false},
|
||||
{int64(1574812326), false},
|
||||
{int(1574812326), false},
|
||||
{uint(1574812326), false},
|
||||
{uint64(1574812326), false},
|
||||
{json.Number("1574812326"), false},
|
||||
{1574812326.000, false},
|
||||
{time.Duration(3) * time.Minute, false},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run("", func(t *testing.T) {
|
||||
_, err := ExpToInt64(testCase.exp)
|
||||
if err != nil && !testCase.expectedFailure {
|
||||
t.Errorf("Expected success but got failure %s", err)
|
||||
}
|
||||
if err == nil && testCase.expectedFailure {
|
||||
t.Error("Expected failure but got success")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsAccessKeyValid(t *testing.T) {
|
||||
testCases := []struct {
|
||||
|
||||
Reference in New Issue
Block a user