feat: add api for getting configurations

This commit is contained in:
Lakhan Samani
2021-12-31 17:24:22 +05:30
parent 9c8e9baa39
commit f7f1a3e4b3
8 changed files with 95 additions and 61 deletions

View File

@@ -0,0 +1,28 @@
package test
import (
"log"
"testing"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/resolvers"
"github.com/authorizerdev/authorizer/server/utils"
"github.com/stretchr/testify/assert"
)
func configTests(s TestSetup, t *testing.T) {
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)
h, err := utils.HashPassword(constants.EnvData.ADMIN_SECRET)
assert.Nil(t, err)
req.Header.Add("Authorization", "Bearer "+h)
res, err := resolvers.ConfigResolver(ctx)
assert.Nil(t, err)
assert.Equal(t, *res.AdminSecret, constants.EnvData.ADMIN_SECRET)
})
}

View File

@@ -47,6 +47,7 @@ func TestResolvers(t *testing.T) {
adminLoginTests(s, t)
adminSessionTests(s, t)
updateConfigTests(s, t)
configTests(s, t)
})
}
}