Commit 977b97e1 authored by Nikos Psaromanolakis's avatar Nikos Psaromanolakis
Browse files

add portal and master features

parent 205526a9
Loading
Loading
Loading
Loading
+29
Changes for pom.xml: 29 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -19,6 +19,35 @@
      <version>${karate.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.github.bonigarcia</groupId>
      <artifactId>webdrivermanager</artifactId>
      <version>5.6.3</version>
      <scope>test</scope>
    </dependency>
    <!-- Selenium -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>4.15.0</version>
        <scope>test</scope>
    </dependency>

  <!-- WebDriver Manager -->
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>5.6.3</version>
        <scope>test</scope>
    </dependency>

    <!-- Chrome Driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>4.15.0</version>
        <scope>test</scope>
    </dependency>
    </dependencies>

  <build>
+2
Changes for src/test/resources/hypo/afterScenario.js: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ function() {
        karate.call('classpath:hypo/deleteAll.feature@deleteServiceOrderAfter', { auth_token: token, orderId: sOrderK8sId });
        }
        if (networkControllerId) {


        karate.call('classpath:hypo/deleteAll.feature@deleteFabricNetwork', { token: token, networkControllerId: networkControllerId });
        }
        karate.call('classpath:hypo/deleteAll.feature@deletePeeringAfter',      { auth_token: token, orgId: cleanupId });
+33
Changes for src/test/resources/hypo/orchestratorMasterNightly.feature: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
@nightly-workflow
Feature: Master Orchestrator - Run all tests sequentially - Nightly Tests

  Scenario: Execute all orchestrators one by one 
    
    * karate.log('========================================')
    * karate.log('STARTING MASTER-NIGHTLY ORCHESTRATOR') 
    * karate.log('========================================')
    
     # Test 1
    * karate.log('#################### 1) Running Portal Orchestrator... ####################')
    * call read('classpath:hypo/orchestratorPortal.feature')
    * karate.log('------ Tests for the Portal PASSED ------')
    
    # Test 2
    * karate.log('#################### 2) Running Private Orchestrator... ####################')
    * call read('classpath:hypo/orchestratorPrivate.feature')
    * karate.log('------ Tests with a private cluster PASSED ------')
    
    # Test 3
    * karate.log('#################### 3) Running Public Orchestrator... ####################')
    * call read('classpath:hypo/orchestratorPublic.feature')
    * karate.log('------ Tests with a public PASSED ------')
    
    # Test 4
    * karate.log('#################### 4) Running OCM Orchestrator... ####################')
    * call read('classpath:hypo/orchestratorOCM.feature')
    * karate.log('------ Tests with a OCM PASSED ------')
    

    * karate.log('========================================')
    * karate.log('------ ALL TESTS PASSED ------')
    * karate.log('========================================')
 No newline at end of file
+167
Changes for src/test/resources/hypo/orchestratorPortal.feature: 167 added lines, 0 removed lines.
Original line number Diff line number Diff line
@portal-login-test
Feature: Portal Login via Keycloak - Complete Flow

  Scenario: Navigate to Portal, Click Keycloak Login, Enter Credentials, Access Portal

    * def portalUsername = keycloakUsername
    * def portalPassword = keycloakPassword

    * def loginPortal = 
      """
      function() {
          var WebDriverManager = Java.type('io.github.bonigarcia.wdm.WebDriverManager');
          var ChromeDriver = Java.type('org.openqa.selenium.chrome.ChromeDriver');
          var By = Java.type('org.openqa.selenium.By');
          var WebDriverWait = Java.type('org.openqa.selenium.support.ui.WebDriverWait');
          var ExpectedConditions = Java.type('org.openqa.selenium.support.ui.ExpectedConditions');
          var Duration = Java.type('java.time.Duration');
          
          WebDriverManager.chromedriver().setup();
          var driver = new ChromeDriver();
          var wait = new WebDriverWait(driver, Duration.ofSeconds(20));
          
          try {
              karate.log('1) Navigating to HypO Portal...');
              driver.get(portalUrl);
              java.lang.Thread.sleep(3000);
              
              var clearBrowserData = function() {
                  driver.manage().deleteAllCookies();
                  try {
                      var jsExecutor = driver;
                      jsExecutor.executeScript('window.localStorage.clear();');
                      jsExecutor.executeScript('window.sessionStorage.clear();');
                      karate.log('Cookies and storage cleared');
                  } catch (e) {
                      karate.log('Could not clear storage: ' + e.message);
                  }
              }
              
              clearBrowserData();
              karate.log('2) Current window handles: ' + driver.getWindowHandles().size());
              var originalWindow = driver.getWindowHandle();
              
              karate.log('3) Clicking Keycloak Login button...');
              driver.findElement(By.xpath("//button[contains(text(), 'Keycloak Login')]")).click();
              
              java.lang.Thread.sleep(5000);
              
              var windowHandles = driver.getWindowHandles();
              karate.log('Window handles after click: ' + windowHandles.size());
              
              if (windowHandles.size() > 1) {
                  karate.log('4) New window detected! Switching to it...');
                  var iterator = windowHandles.iterator();
                  while (iterator.hasNext()) {
                      var handle = iterator.next();
                      if (!handle.equals(originalWindow)) {
                          driver.switchTo().window(handle);
                          karate.log('Switched to new window: ' + handle);
                          break;
                      }
                  }
              }
              
              java.lang.Thread.sleep(3000);
              karate.log('5) Current URL: ' + driver.getCurrentUrl());
              
              karate.log('6) Waiting for username input...');
              wait.until(ExpectedConditions.presenceOfElementLocated(By.name('username')));
              
              karate.log('7) Found username input! Entering credentials...');
              driver.findElement(By.name('username')).sendKeys(portalUsername);
              java.lang.Thread.sleep(500);
              
              karate.log('8) Entering password...');
              driver.findElement(By.name('password')).sendKeys(portalPassword);
              java.lang.Thread.sleep(500);
              
              karate.log('9) Clicking login button...');
              driver.findElement(By.id('kc-login')).click();
              
              karate.log('10) Waiting for redirect back to portal...');
              java.lang.Thread.sleep(5000);
              
              if (driver.getWindowHandles().size() > 1) {
                  karate.log('Switching back to original window...');
                  driver.switchTo().window(originalWindow);
                  java.lang.Thread.sleep(2000);
              }
              
              var currentUrl = driver.getCurrentUrl();
              karate.log('11) Current URL after login: ' + currentUrl);
              
              // ========== CHECK IF SIGNUP PAGE ==========
              if (currentUrl.contains('/signup')) {
                  karate.log('11a) SIGNUP PAGE detected! Filling signup form...');
                  
                  // Fill Full Name field
                  karate.log('11b) Looking for Full Name field...');
                  wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[contains(@placeholder, 'name') or contains(@placeholder, 'Name')]")));
                  
                  var fullNameInput = driver.findElement(By.xpath("//input[contains(@placeholder, 'name') or contains(@placeholder, 'Name') or contains(@name, 'name')]"));
                  fullNameInput.clear();
                  fullNameInput.sendKeys(portalUsername);
                  karate.log('11c) Entered username in Full Name field');
                  java.lang.Thread.sleep(500);
                  
                  // Click Create Account button
                  karate.log('11d) Looking for Create Account button...');
                  var createBtn = driver.findElement(By.xpath("//button[contains(text(), 'Create')]"));
                  createBtn.click();
                  karate.log('11e) Clicked Create Account button');
                  
                  java.lang.Thread.sleep(5000);
                  karate.log('11f) Waiting for redirect back to portal...');
                  
                  var redirectUrl = driver.getCurrentUrl();
                  karate.log('11g) Redirected to: ' + redirectUrl);
              } else {
                  karate.log('11b) Already at PORTAL - skipping signup');
              }
              
              // ========== CLICK MARKETPLACE ==========
              karate.log('13) Looking for Marketplace...');
              
              var marketplaceLink = null;
              var allDivs = driver.findElements(By.tagName('div'));
              for (var i = 0; i < allDivs.size(); i++) {
                  var divText = allDivs.get(i).getText().trim();
                  if (divText.equals('MARKETPLACE')) {
                      marketplaceLink = allDivs.get(i);
                      break;
                  }
              }
              
              if (marketplaceLink == null) {
                  karate.fail('MARKETPLACE element not found');
              }
              
              karate.log('14) Clicking MARKETPLACE...');
              var jsExecutor = driver;
              jsExecutor.executeScript('arguments[0].scrollIntoView({block: "center"});', marketplaceLink);
              java.lang.Thread.sleep(500);
              marketplaceLink.click();
              java.lang.Thread.sleep(4000);
              
              var finalUrl = driver.getCurrentUrl();
              karate.log('15) Navigated to: ' + finalUrl);
              
              java.lang.Thread.sleep(4000);
              
              var finalUrl = driver.getCurrentUrl();
              karate.log('16) Final URL: ' + finalUrl);
              
              return { success: true, url: finalUrl };
          } catch (e) {
              karate.log('Error: ' + e.message);
              karate.fail('Portal flow failed: ' + e.message);
          } finally {
              driver.quit();
          }
      }
      """
    
    * def result = loginPortal()
    * match result.success == true
    * karate.log('---- PORTAL TEST PASSED ----')
 No newline at end of file
−145

File deleted.

Loading