From aa99835d5c675383b6051d7cf36c491a26830d8f Mon Sep 17 00:00:00 2001 From: Garrett Ladley <92384606+garrettladley@users.noreply.github.com> Date: Sun, 9 Jun 2024 21:49:06 -0400 Subject: [PATCH] fix: mock out auth flow in test (#980) --- backend/tests/api/helpers/auth.go | 42 +------------------------------ 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/backend/tests/api/helpers/auth.go b/backend/tests/api/helpers/auth.go index 897e094f..32b32ce7 100644 --- a/backend/tests/api/helpers/auth.go +++ b/backend/tests/api/helpers/auth.go @@ -1,11 +1,7 @@ package helpers import ( - "fmt" - - "github.com/GenerateNU/sac/backend/database" "github.com/GenerateNU/sac/backend/entities/models" - "github.com/gofiber/fiber/v2" "github.com/google/uuid" ) @@ -25,43 +21,7 @@ func (app *TestApp) Auth(role models.UserRole) { } func (app *TestApp) authSuper() { - superUser, superUserErr := database.SuperUser(app.Settings.SuperUser) - if superUserErr != nil { - panic(fmt.Sprintf("Failed to get super user: %v", superUserErr)) - } - - email := superUser.Email - password := app.Settings.SuperUser.Password - - resp, err := app.Send(TestRequest{ - Method: fiber.MethodPost, - Path: "/api/v1/auth/login", - Body: &map[string]interface{}{ - "email": email, - "password": password.Expose(), - }, - }) - if err != nil { - panic(fmt.Sprintf("Failed to authenticate super user: %v", err)) - } - - var accessToken string - var refreshToken string - - authHeader := resp.Header.Get("Authorization") - if authHeader != "" { - accessToken = authHeader[len("Bearer "):] - } - - if accessToken == "" || refreshToken == "" { - panic("Failed to authenticate super user") - } - - app.TestUser = &TestUser{ - UUID: database.SuperUserUUID, - Email: email, - AccessToken: accessToken, - } + app.TestUser = nil } func (app *TestApp) authStudent() {