added dynamic params and seprate the update logic for common use

This commit is contained in:
manoj
2022-12-17 15:13:45 +05:30
parent 2d968309bb
commit 1b2483d47f
18 changed files with 182 additions and 195 deletions

View File

@@ -2,7 +2,6 @@ package test
import (
"testing"
"time"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/db"
@@ -22,7 +21,6 @@ func forgotPasswordTest(t *testing.T, s TestSetup) {
ConfirmPassword: s.TestInfo.Password,
})
time.Sleep(500 * time.Millisecond)
_, err = resolvers.ForgotPasswordResolver(ctx, model.ForgotPasswordInput{
Email: email,
})

View File

@@ -5,6 +5,7 @@ import (
"os"
"strings"
"testing"
"time"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/db"
@@ -36,7 +37,7 @@ func TestResolvers(t *testing.T) {
} else {
t.Log("waiting for docker containers to start...")
// wait for docker containers to spun up
// time.Sleep(30 * time.Second)
time.Sleep(30 * time.Second)
}
testDb := "authorizer_test"

View File

@@ -3,7 +3,6 @@ package test
import (
"fmt"
"testing"
"time"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/crypto"
@@ -23,7 +22,6 @@ func revokeAccessTest(t *testing.T, s TestSetup) {
Email: email,
})
assert.NoError(t, err)
time.Sleep(4 * time.Second)
verificationRequest, err := db.Provider.GetVerificationRequestByEmail(ctx, email, constants.VerificationTypeMagicLinkLogin)
verifyRes, err := resolvers.VerifyEmailResolver(ctx, model.VerifyEmailInput{
Token: verificationRequest.Token,

View File

@@ -1,7 +1,6 @@
package test
import (
"fmt"
"testing"
"github.com/authorizerdev/authorizer/server/constants"
@@ -56,9 +55,6 @@ func signupTests(t *testing.T, s TestSetup) {
ConfirmPassword: s.TestInfo.Password,
})
fmt.Println("err", err)
fmt.Println("res", res)
assert.NotNil(t, err, "should throw duplicate email error")
verificationRequest, err := db.Provider.GetVerificationRequestByEmail(ctx, email, constants.VerificationTypeBasicAuthSignup)

View File

@@ -108,10 +108,8 @@ func testSetup() TestSetup {
memorystore.Provider.UpdateEnvVariable(constants.EnvKeySmtpPassword, "test")
memorystore.Provider.UpdateEnvVariable(constants.EnvKeySenderEmail, "info@yopmail.com")
memorystore.Provider.UpdateEnvVariable(constants.EnvKeyProtectedRoles, "admin")
fmt.Println("called test suite before")
err = db.InitDB()
fmt.Println("called test suite")
if err != nil {
log.Fatal("Error loading db: ", err)
}

View File

@@ -3,7 +3,6 @@ package test
import (
"fmt"
"testing"
"time"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/db"
@@ -42,12 +41,10 @@ func updateAllUsersTest(t *testing.T, s TestSetup) {
Offset: 0,
})
assert.NoError(t, err)
time.Sleep(500 * time.Millisecond)
for _, u := range listUsers.Users {
assert.True(t, refs.BoolValue(u.IsMultiFactorAuthEnabled))
}
time.Sleep(1 * time.Second)
// // update few users
updateIds := []string{listUsers.Users[0].ID, listUsers.Users[1].ID}

View File

@@ -3,7 +3,6 @@ package test
import (
"fmt"
"testing"
"time"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/crypto"
@@ -15,7 +14,6 @@ import (
)
func webhookLogsTest(t *testing.T, s TestSetup) {
time.Sleep(30 * time.Second) // add sleep for webhooklogs to get generated as they are async
t.Helper()
t.Run("should get webhook logs", func(t *testing.T) {
req, ctx := createContext(s)
@@ -25,11 +23,7 @@ func webhookLogsTest(t *testing.T, s TestSetup) {
assert.NoError(t, err)
req.Header.Set("Cookie", fmt.Sprintf("%s=%s", constants.AdminCookieName, h))
time.Sleep(1 * time.Second)
webhookLogs, err := resolvers.WebhookLogsResolver(ctx, nil)
fmt.Printf("webhookLogs=========== %+v \n", webhookLogs.WebhookLogs)
time.Sleep(20 * time.Second)
fmt.Println("total documents found", len(webhookLogs.WebhookLogs))
assert.NoError(t, err)
assert.Greater(t, len(webhookLogs.WebhookLogs), 1)