Ver código fonte

fix: Wait for login UI to appear in authRequireGuestsToLogin test

jamesread 8 meses atrás
pai
commit
c89979ddb2

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
frontend/resources/scripts/gen/olivetin/api/v1/olivetin_pb.js


+ 15 - 2
integration-tests/test/authRequireGuestsToLogin.mjs

@@ -30,8 +30,21 @@ describe('config: authRequireGuestsToLogin', function () {
 
     // Navigate directly to login to avoid SPA timing issues
     await webdriver.get(runner.baseUrl() + '/login')
-    // Wait for login form to be present
-    await webdriver.wait(until.elementLocated(By.css('form.local-login-form, button.login-button, input[name="username"]')), 20000)
+    // Wait for Init to load and then for login UI to appear (local or OAuth)
+    await webdriver.wait(async () => {
+      const hasInit = await webdriver.executeScript('return !!window.initResponse')
+      if (!hasInit) return false
+
+      const hasLocal = await webdriver.executeScript('return !!(window.initResponse && window.initResponse.authLocalLogin)')
+      if (hasLocal) {
+        const els = await webdriver.findElements(By.css('form.local-login-form, button.login-button, input[name="username"]'))
+        if (els.length > 0) return true
+      }
+
+      // If local login not enabled, ensure OAuth or disabled message renders
+      const alt = await webdriver.findElements(By.css('.login-oauth2, .login-disabled'))
+      return alt.length > 0
+    }, 5000)
     
     // Verify we're on the login page
     const currentUrlAtLogin = await webdriver.getCurrentUrl()

+ 0 - 44
service/internal/httpservers/restapi.go

@@ -1,44 +0,0 @@
-package httpservers
-
-import (
-	"net/http"
-	"strings"
-
-	log "github.com/sirupsen/logrus"
-
-	//	apiv1 "github.com/OliveTin/OliveTin/gen/olivetin/api/v1"
-
-	config "github.com/OliveTin/OliveTin/internal/config"
-)
-
-func parseHttpHeaderForAuth(cfg *config.Config, req *http.Request) (string, string) {
-	username, ok := req.Header[cfg.AuthHttpHeaderUsername]
-
-	if !ok {
-		log.Warnf("Config has AuthHttpHeaderUsername set to %v, but it was not found", cfg.AuthHttpHeaderUsername)
-
-		return "", ""
-	}
-
-	if cfg.AuthHttpHeaderUserGroup != "" {
-		usergroup, ok := req.Header[cfg.AuthHttpHeaderUserGroup]
-
-		if ok {
-			log.Debugf("HTTP Header Auth found a username and usergroup")
-
-			return username[0], usergroup[0]
-		} else {
-			log.Warnf("Config has AuthHttpHeaderUserGroup set to %v, but it was not found", cfg.AuthHttpHeaderUserGroup)
-		}
-	}
-
-	log.Debugf("HTTP Header Auth found a username, but usergroup is not being used")
-
-	return username[0], ""
-}
-
-//gocyclo:ignore
-func parseJwtHeader(cfg *config.Config, req *http.Request) (string, string) {
-	// JWTs in the Authorization header are usually prefixed with "Bearer " which is not part of the JWT token.
-	return parseJwt(cfg, strings.TrimPrefix(req.Header.Get(cfg.AuthJwtHeader), "Bearer "))
-}

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff