2022-01-17 06:02:13 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/authorizerdev/authorizer/server/constants"
|
2022-02-28 15:56:49 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/crypto"
|
2022-05-30 03:49:55 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/memorystore"
|
2022-01-17 06:02:13 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/resolvers"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func adminLogoutTests(t *testing.T, s TestSetup) {
|
|
|
|
t.Helper()
|
|
|
|
t.Run(`should get admin session`, func(t *testing.T) {
|
|
|
|
req, ctx := createContext(s)
|
|
|
|
_, err := resolvers.AdminLogoutResolver(ctx)
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
|
2022-05-30 03:49:55 +00:00
|
|
|
h, err := crypto.EncryptPassword(memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyAdminSecret))
|
2022-01-17 06:02:13 +00:00
|
|
|
assert.Nil(t, err)
|
2022-05-30 03:49:55 +00:00
|
|
|
req.Header.Set("Cookie", fmt.Sprintf("%s=%s", memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyAdminCookieName), h))
|
2022-01-17 06:02:13 +00:00
|
|
|
_, err = resolvers.AdminLogoutResolver(ctx)
|
|
|
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
|
|
|
}
|