babangsund / cypress-keycloak

Cypress commands for Keycloak
MIT License
43 stars 39 forks source link

Impossible to Login, my app keep redirect me to keycloak after calling cy.login #14

Closed IzioDev closed 3 years ago

IzioDev commented 3 years ago

Versions :

Here is my test :

describe('Admin / login page', () => {
  before(() => {
    cy.task('db:seed');
    cy.mailhog('clear');
  });

  it('Should login', () => {
    cy.login({
      client_id: 'admin',
      password: 'adminadmin',
      realm: 'bilik',
      redirect_uri: 'http://admin.devbilik.loc/',
      root: 'http://auth.traefik.loc',
      username: 'admin@bilik.fr',
    }).then((el) => {
      console.log(el);

      cy.visit(`${Cypress.env('ADMIN_URL')}/`);
      cy.get('#username').type('admin@bilik.fr');
      cy.get('#password').type('adminadmin');
      cy.get('#kc-login').click();
    });

    // cy.contains('Tableau de bord');
    // cy.logout();
  });
});

For some reasons, the requests seems to pass (requests from the cypress-keycloak plugin) : image

But when I do a cy.visit() right after the login, my app keep redirecting me. It's a react app. The funny thing is when I login though the Cypress browser, it's working perfectly : http://auth.traefik.loc/auth/realms/bilik/protocol/openid-connect/auth?client_id=admin&redirect_uri=http%3A%2F%2Fadmin.devbilik.loc%2F&state=09736f9f-73c9-473a-93b7-1f6542102309&response_mode=fragment&response_type=code&scope=openid%20offline_access&nonce=2399c1c6-7752-48a7-8f57-cdc472e66a4b

What do I miss here ? Thanks.

KaiSpencer commented 2 years ago

@IzioDev did you solve this? Having the same issue

plebcity commented 2 years ago

@IzioDev Did you solve this? I'm having the exact same problem and can't find a solution

vosamoilenko commented 2 years ago

@IzioDev +1