Trying to incorporate the automation of Azure AD login using Cypress, I have been facing some challenges. Even after configuring the local session storage according to the instructions in this GitHub repository https://github.com/juunas11/AzureAdUiTestAutomation, the tests keep redirecting to the Microsoft authentication page and opening outside the Cypress window. Any assistance on resolving this issue would be highly appreciated as it has halted my progress with the automation. enter image description here
/// <reference types="cypress" />
import { decode, JwtPayload } from 'jsonwebtoken';
import authSettings from './authsettings.json';
// All necessary details stored in a separate file (authSettings.js)
const {
authority,
clientId,
clientSecret,
apiScopes,
username,
password,
apiScopesEntity,
targetScopes,
} = authSettings;
const environment = 'login.windows.net';
// Functions for building different token entities
const injectTokens = (tokenResponse) => {
// Code for injecting tokens into local and session storage
};
export const login = () => {
let tokenResponse = null;
cy.request({
url: authority + '/oauth2/v2.0/token',
method: 'POST',
body: {
grant_type: 'password',
client_id: clientId,
client_secret: clientSecret,
scope: apiScopes,
username: username,
password: password,
},
form: true,
})
.then((response) => {
injectTokens(response.body);
tokenResponse = response.body.access_token;
})
.reload()
.then(() => {
return tokenResponse;
});
};