2022-05-04 12:29:11 +00:00
|
|
|
package authmate
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-03-07 14:38:08 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session"
|
2022-05-04 12:29:11 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestContainerSessionRules(t *testing.T) {
|
|
|
|
jsonRules := []byte(`
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"verb": "PUT",
|
|
|
|
"containerID": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"verb": "DELETE",
|
|
|
|
"containerID": "6CcWg8LkcbfMUC8pt7wiy5zM1fyS3psNoxgfppcCgig1"
|
|
|
|
}
|
|
|
|
]`)
|
|
|
|
|
|
|
|
sessionContext, err := buildContext(jsonRules)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-05-28 09:10:28 +00:00
|
|
|
require.Len(t, sessionContext, 2)
|
2022-05-04 12:29:11 +00:00
|
|
|
require.Equal(t, sessionContext[0].verb, session.VerbContainerPut)
|
2022-06-27 09:33:36 +00:00
|
|
|
require.Zero(t, sessionContext[0].containerID)
|
2022-05-04 12:29:11 +00:00
|
|
|
require.Equal(t, sessionContext[1].verb, session.VerbContainerDelete)
|
|
|
|
require.NotNil(t, sessionContext[1].containerID)
|
|
|
|
}
|