authorizer/server/test/env_test.go

32 lines
1005 B
Go
Raw Normal View History

2022-01-17 06:02:13 +00:00
package test
import (
2022-01-17 07:42:46 +00:00
"fmt"
"log"
2022-01-17 06:02:13 +00:00
"testing"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/envstore"
2022-01-17 07:42:46 +00:00
"github.com/authorizerdev/authorizer/server/resolvers"
"github.com/authorizerdev/authorizer/server/utils"
2022-01-17 06:02:13 +00:00
"github.com/stretchr/testify/assert"
)
2022-01-17 07:42:46 +00:00
func configTests(t *testing.T, s TestSetup) {
t.Helper()
t.Run(`should get config`, func(t *testing.T) {
req, ctx := createContext(s)
_, err := resolvers.EnvResolver(ctx)
log.Println("error:", err)
assert.NotNil(t, err)
2022-01-17 06:02:13 +00:00
2022-01-17 07:42:46 +00:00
h, err := utils.EncryptPassword(envstore.EnvInMemoryStoreObj.GetEnvVariable(constants.EnvKeyAdminSecret).(string))
assert.Nil(t, err)
req.Header.Set("Cookie", fmt.Sprintf("%s=%s", envstore.EnvInMemoryStoreObj.GetEnvVariable(constants.EnvKeyAdminCookieName).(string), h))
res, err := resolvers.EnvResolver(ctx)
assert.Nil(t, err)
assert.Equal(t, *res.AdminSecret, envstore.EnvInMemoryStoreObj.GetEnvVariable(constants.EnvKeyAdminSecret).(string))
})
2022-01-17 06:02:13 +00:00
}