Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[ui5-middleware-onelogin] Login with SAP Passport Certificate #1078

Open
marianfoo opened this issue Sep 13, 2024 · 0 comments · May be fixed by #1079
Open

[ui5-middleware-onelogin] Login with SAP Passport Certificate #1078

marianfoo opened this issue Sep 13, 2024 · 0 comments · May be fixed by #1079

Comments

@marianfoo
Copy link
Member

Since Playwright Version 1.46 it is possible to provide a certificate to login.
It would make sense to integrate this into the login middleware.

In a minimal sample i was able to login with my SAP Passport X.509 Certificate in pfx format:

playwright.config.ts

import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    headless: false, // Set to true if you want headless mode
    viewport: { width: 1280, height: 720 },
    ignoreHTTPSErrors: false,
    clientCertificates: [
    {
        origin: 'https://accounts.sap.com',
        pfxPath: 'sap.pfx',
        passphrase: 'XXX',       // Password for the .pfx file
      }
    ]
  },
});

sap-login.spec.ts

import { test, expect } from '@playwright/test';

test('Login to SAP BTP Cockpit with client certificate', async ({ page }) => {
  // Go to the SAP BTP Cockpit URL
  await page.goto('https://emea.cockpit.btp.cloud.sap/cockpit#/');

  // Wait for the login page to load (adjust the selector based on the actual login form structure)
  await expect(page).toHaveURL('https://emea.cockpit.btp.cloud.sap/cockpit#/');
  
  // You can add further checks to ensure successful login based on page content, URL change, etc.
  // add 10 seconds wait
  await page.waitForTimeout(10000);

  // Take a screenshot of the page
  await page.screenshot({ path: 'screenshot.png' });

});

package.json

{
  "name": "sap-certificate-auth",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@playwright/test": "^1.48.0-alpha-2024-09-13",
    "@types/node": "^22.5.4",
    "typescript": "^5.6.2"
  }
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
1 participant