2022-01-17 07:42:46 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/authorizerdev/authorizer/server/constants"
|
|
|
|
"github.com/authorizerdev/authorizer/server/env"
|
2022-05-30 03:49:55 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/memorystore"
|
2022-05-30 07:17:50 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/utils"
|
2022-01-17 07:42:46 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEnvs(t *testing.T) {
|
2022-05-30 07:17:50 +00:00
|
|
|
memorystore.Provider.UpdateEnvVariable(constants.EnvKeyEnvPath, "../../.env.sample")
|
2022-02-26 04:14:55 +00:00
|
|
|
env.InitAllEnv()
|
2022-05-30 07:17:50 +00:00
|
|
|
store, err := memorystore.Provider.GetEnvStore()
|
|
|
|
assert.Nil(t, err)
|
2022-01-17 07:42:46 +00:00
|
|
|
|
2022-05-30 07:17:50 +00:00
|
|
|
assert.Equal(t, store[constants.EnvKeyEnv].(string), "production")
|
|
|
|
assert.False(t, store[constants.EnvKeyDisableEmailVerification].(bool))
|
|
|
|
assert.False(t, store[constants.EnvKeyDisableMagicLinkLogin].(bool))
|
|
|
|
assert.False(t, store[constants.EnvKeyDisableBasicAuthentication].(bool))
|
|
|
|
assert.Equal(t, store[constants.EnvKeyJwtType].(string), "RS256")
|
|
|
|
assert.Equal(t, store[constants.EnvKeyJwtRoleClaim].(string), "role")
|
|
|
|
assert.EqualValues(t, utils.ConvertInterfaceToStringSlice(store[constants.EnvKeyRoles]), []string{"user"})
|
|
|
|
assert.EqualValues(t, utils.ConvertInterfaceToStringSlice(store[constants.EnvKeyDefaultRoles]), []string{"user"})
|
|
|
|
assert.EqualValues(t, utils.ConvertInterfaceToStringSlice(store[constants.EnvKeyAllowedOrigins]), []string{"*"})
|
2022-01-17 07:42:46 +00:00
|
|
|
}
|