2022-07-11 05:12:42 +00:00
|
|
|
package test
|
2022-07-11 14:10:54 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/authorizerdev/authorizer/server/constants"
|
|
|
|
"github.com/authorizerdev/authorizer/server/crypto"
|
2023-03-29 01:36:33 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
2022-07-11 14:10:54 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/memorystore"
|
2023-03-29 01:36:33 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/refs"
|
2022-07-11 14:10:54 +00:00
|
|
|
"github.com/authorizerdev/authorizer/server/resolvers"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func webhooksTest(t *testing.T, s TestSetup) {
|
|
|
|
t.Helper()
|
|
|
|
t.Run("should get webhooks", func(t *testing.T) {
|
|
|
|
req, ctx := createContext(s)
|
|
|
|
adminSecret, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyAdminSecret)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
h, err := crypto.EncryptPassword(adminSecret)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
req.Header.Set("Cookie", fmt.Sprintf("%s=%s", constants.AdminCookieName, h))
|
|
|
|
|
2023-03-29 01:36:33 +00:00
|
|
|
webhooks, err := resolvers.WebhooksResolver(ctx, &model.PaginatedInput{
|
|
|
|
Pagination: &model.PaginationInput{
|
|
|
|
Limit: refs.NewInt64Ref(20),
|
|
|
|
},
|
|
|
|
})
|
2022-07-11 14:10:54 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEmpty(t, webhooks)
|
2023-07-23 01:59:29 +00:00
|
|
|
assert.GreaterOrEqual(t, len(webhooks.Webhooks), len(s.TestInfo.TestWebhookEventTypes)*2)
|
2022-07-11 14:10:54 +00:00
|
|
|
})
|
|
|
|
}
|