Files
authorizer/server/test/env_test.go

30 lines
970 B
Go
Raw Normal View History

2022-01-17 11:32:13 +05:30
package test
import (
2022-01-17 13:12:46 +05:30
"fmt"
2022-01-17 11:32:13 +05:30
"testing"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/envstore"
2022-01-17 13:12:46 +05:30
"github.com/authorizerdev/authorizer/server/resolvers"
"github.com/authorizerdev/authorizer/server/utils"
2022-01-17 11:32:13 +05:30
"github.com/stretchr/testify/assert"
)
func envTests(t *testing.T, s TestSetup) {
2022-01-17 13:12:46 +05:30
t.Helper()
t.Run(`should get envs`, func(t *testing.T) {
2022-01-17 13:12:46 +05:30
req, ctx := createContext(s)
_, err := resolvers.EnvResolver(ctx)
assert.NotNil(t, err)
2022-01-17 11:32:13 +05:30
h, err := utils.EncryptPassword(envstore.EnvInMemoryStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAdminSecret))
2022-01-17 13:12:46 +05:30
assert.Nil(t, err)
req.Header.Set("Cookie", fmt.Sprintf("%s=%s", envstore.EnvInMemoryStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAdminCookieName), h))
2022-01-17 13:12:46 +05:30
res, err := resolvers.EnvResolver(ctx)
assert.Nil(t, err)
assert.Equal(t, *res.AdminSecret, envstore.EnvInMemoryStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAdminSecret))
2022-01-17 13:12:46 +05:30
})
2022-01-17 11:32:13 +05:30
}