0

アプリのサインインページをテストしようとしていました。サイプレスを使用して、Vuejs フロントエンドが AspNet Api で動作することをテストしています。クロムのサインインボタンをクリックすると、次のリクエストが行われ、ホームページ「localhost:44389」にアクセスします

Chrome からの最初のリクエスト

Chrome からの 2 番目のリクエスト

サイプレスでシミュレートしたい場合、同じリクエストを送信しますが、200 ではなく 2 番目のリクエストから 302 を取得します。

サイプレスからの最初の要求

Cypress からの 2 回目のリクエスト

誰かが問題を見つけるのを手伝ってくれますか?

Cypress.Commands.add('IdentityServerAPILogin', (email, password) => {
  
  console.log("SERVER_URL is called. Server: " + Cypress.env('SERVER_URL'));
  
  cy.request({
    method: 'GET',
    url: Cypress.env('SERVER_URL'),
    failOnStatusCode: false,
    headers: {
      'Cookie': '...coookies...'
    }
    })
    .then(response => {
      if (response.status == 401){
        console.log ("Check for NOnce");
        console.dir(response, { depth: null });
        const requestURL = response.allRequestResponses[1]["Request URL"]
        console.dir(requestURL, { depth: null })
        //const signInPage = (response.redirects[0]).replace('302: ', '');
        const signInPage = (response.redirects[1]).replace('302: ', '');
        console.log("signInPage:" + signInPage);
        const nOnceObj = response.allRequestResponses[0]["Response Headers"];
        console.dir(nOnceObj, { depth: null });
        const nOnce = nOnceObj["set-cookie"][0];
        console.log("Nonce:" + nOnce);
        cy.visit({
          method: 'GET',
          url: signInPage,
          failOnStatusCode: false,
          headers: {
            //'Cookie': nOnce
          }
        })
        // TODO: Create all needed tests later to test sign in
        cy.get('#username').type(email)
        cy.get('#password').type(password)
        // TODO: Waiting for to click signIn button. When I call the click() method I get infinite loop!!
        cy.get('.ping-button')
        // .click()
        //  .then((response_login) => {
        //     console.log("Status REsponse_Login: "+ response_login);
        //     console.dir(response_login, { depth: null });
        //     if (response_login.status == 401){
        //     cy.visit(Cypress.env('SERVER_URL'))  
        //     }     
        //   })
      }else
        cy.visit(Cypress.env('SERVER_URL'))             
    })  
  console.log("vorbei");
});

.../signin-oidc下の写真のようなエラーがあるため、Cypress が から Cookie を取得できないことがわかりました。

SameSite=Lax エラー

親切に解決策を求めます。認証サービスを変更することはできません。ヒノキの周りの可能性を探しています。

4

0 に答える 0