ui5-uiveri5 icon indicating copy to clipboard operation
ui5-uiveri5 copied to clipboard

Long wait when using github-authenticator

Open DenisDuev opened this issue 5 years ago • 10 comments

We try switching from sapcloud-form togithub-form (v1.42.1 - e.g. latest) and found some strange behaviour:

When there is authorize button everything is working fine. When there is no such button the test freezes on DEBUG: Opening custom login page and wait for ~ 2-3 minutes (the whole test takes 209.38 seconds) when using sapcloud-from the test takes ~ 14.72 second

I suppose it freezes because of https://github.com/SAP/ui5-uiveri5/blob/master/src/authenticator/formAuthenticator.js#L97:

this._wait(function() {
      return that._isPresent(that.authorizationButtonSelector).then(function(isPresent) {
        if (isPresent) {
          return that._getField(that.authorizationButtonSelector).click().then(function() {
            return true;
          });
        }
      });
    },'Explicit authorization was not requested',this.authorizationButtonTimeout).catch(function () {
      // swallow the timeout error as reauthorization is only displayed sometimes
    });

Which waits for authorize button, but the button appears only from time to time.

Consider something as in the original implementation, where if the button:

  • visible, but:
    • disabled -> wait for it then click it
    • enabled -> click it
  • not visible (not there):
    • stop waiting and continue

This can be seen in: https://github.com/SAP/ui5-uiveri5/commit/9541d298e2fd6618dd32a91d9ee27cfd9f8f68aa#diff-3b06efe14e0d496e33d9216fefee54a0R92

DenisDuev avatar Feb 17 '20 11:02 DenisDuev

Hi, can you please try with v1.42.1 as we did some restructuring in this code ?.

maximnaidenov avatar Feb 17 '20 11:02 maximnaidenov

Yes, my pardon I have written in the description 1.41.2, but meaning 1.42.1 e.g. the latest. The issues is only with github-form when there is not button authorize in all other cases it is working as expected

DenisDuev avatar Feb 17 '20 11:02 DenisDuev

That is strange as we have E2E tests that covers all scenarios of this authenticator and they are working fine. I will have a look and come back to you for details.

maximnaidenov avatar Feb 17 '20 12:02 maximnaidenov

Again it is working (after the long wait the tests work as expected), but it waits for far too much time... more than we can spend for our Pull Request tests.

DenisDuev avatar Feb 17 '20 12:02 DenisDuev

The authorizationButtonTimeout is configurable, default is 10000 ms e.g. 10 sec. https://github.com/SAP/ui5-uiveri5/blob/master/docs/config/authentication.md

maximnaidenov avatar Feb 17 '20 12:02 maximnaidenov

The algorithm you suggested is unreliable as it depends on the current implementation in github and depends on load timing. See the E2E where we validate both the presence and visibility of the button.

maximnaidenov avatar Feb 17 '20 12:02 maximnaidenov

Thanks, the problem seems to be that we have overridden the default timeouts:

  timeouts: {
    getPageTimeout: "200000",
    allScriptsTimeout: "900000",
    defaultTimeoutInterval: "900000"
  },

Where I need to put the authorizationButtonTimeout: "10000", because I tried ii in the timeout section and also under github-form, but it seems that do not work?

I have tested it with removing the custom timeout and it wait for the default time of 10 seconds.

DenisDuev avatar Feb 17 '20 12:02 DenisDuev

Check the docs: https://github.com/SAP/ui5-uiveri5/blob/master/docs/config/authentication.md

maximnaidenov avatar Feb 17 '20 12:02 maximnaidenov

I have checked it, but it does not work. In the file - https://github.com/SAP/ui5-uiveri5/blob/master/src/authenticator/formAuthenticator.js, the timeout is used, but it is undefined (it is not assigned to this in the constructor?) I have tried with adding log right before the check: that.logger.debug('timeout set to:' + this.authorizationButtonTimeout); and I get:
DEBUG: timeout set to:undefined

DenisDuev avatar Feb 17 '20 12:02 DenisDuev

ups, seems we forgot to init. And the test passes which is even worse. Will check and fix soon, sorry.

maximnaidenov avatar Feb 17 '20 12:02 maximnaidenov