authorizer/server/test/config_test.go

32 lines
1011 B
Go
Raw Normal View History

package test
import (
2022-01-09 12:05:37 +00:00
"fmt"
"log"
"testing"
"github.com/authorizerdev/authorizer/server/constants"
2022-01-17 06:02:13 +00:00
"github.com/authorizerdev/authorizer/server/envstore"
"github.com/authorizerdev/authorizer/server/resolvers"
"github.com/authorizerdev/authorizer/server/utils"
"github.com/stretchr/testify/assert"
)
2022-01-17 06:02:13 +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.ConfigResolver(ctx)
log.Println("error:", err)
assert.NotNil(t, err)
2022-01-17 06:02:13 +00:00
h, err := utils.EncryptPassword(envstore.EnvInMemoryStoreObj.GetEnvVariable(constants.EnvKeyAdminSecret).(string))
assert.Nil(t, err)
2022-01-17 06:02:13 +00:00
req.Header.Set("Cookie", fmt.Sprintf("%s=%s", envstore.EnvInMemoryStoreObj.GetEnvVariable(constants.EnvKeyAdminCookieName).(string), h))
res, err := resolvers.ConfigResolver(ctx)
assert.Nil(t, err)
2022-01-17 06:02:13 +00:00
assert.Equal(t, *res.AdminSecret, envstore.EnvInMemoryStoreObj.GetEnvVariable(constants.EnvKeyAdminSecret).(string))
})
}