18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Issue in 401 Authentication

umeshumesh Members
edited November -1 in Sahi - Open Source
Hi,

I am new to Sahi and would like to Congratulate the team for this wonderful tool

Problem statement: -
In my current requirement i am trying to access a webpage which has got 401 authentication. During this process Sahi generates a webpage containing the userid and password field, but on entry of data the page simply refreshes instead of logging in :(

Other information: -

A little analysis of the server trace showed that the basic realm was treated differently when sending the password, the realm had " before and after the realm name, but while sending the password this is being ignored. I have attached the server trace for your reference.

Server trace: -

Aug 11, 2010 5:21:15 PM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
cation
INFO: getRequestingProtocol() = http
Aug 11, 2010 5:21:15 PM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
cation
INFO: realm=; getRequestingScheme()=basic
Aug 11, 2010 5:21:15 PM net.sf.sahi.RemoteRequestProcessor process401
INFO: wwwAuthenticate: Basic realm=""Client name UAT environment""
Aug 11, 2010 5:21:15 PM net.sf.sahi.RemoteRequestProcessor process401
INFO: scheme=basic; realm=Client name UAT environment
Aug 11, 2010 5:21:44 PM net.sf.sahi.RemoteRequestProcessor processHttp
Aug 11, 2010 5:21:44 PM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
cation
INFO: getRequestingProtocol() = http
Aug 11, 2010 5:21:44 PM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
cation
INFO: realm=; getRequestingScheme()=basic
Aug 11, 2010 5:21:44 PM net.sf.sahi.RemoteRequestProcessor process401
INFO: wwwAuthenticate: Basic realm=""Client name UAT environment""
Aug 11, 2010 5:21:44 PM net.sf.sahi.RemoteRequestProcessor process401
INFO: scheme=basic; realm=Client name UAT environment

Thanks for all your help
Umesh

Comments

  • narayannarayan Administrators
    Hi Umesh,

    We have tried to fix this issue and emailed you a link to a new build of Sahi. Could you please verify and let us know if it works?

    Regards,
    Narayan
  • umeshumesh Members
    Hi Narayan,

    Thanks for the super quick reply!!!

    Tried this in the latest build and the issue persists :(, The server trace is attached below, i think the double quotes are still causing some issue.

    Apart from this an error is reported in the IE status bar, on opening the error the message "Object doesn't support this property or method" is observed (Not sure if this is of any significance)

    Server trace: -
    C:\sahi\bin>sahi
    SAHI_HOME: ..
    SAHI_USERDATA_DIR: ..\userdata
    SAHI_EXT_CLASS_PATH:
    Sahi properties file = C:\sahi\config\sahi.properties
    Sahi user properties file = C:\sahi\userdata\config\userdata.properties
    >>>> Sahi started. Listening on port: 9999
    >>>> Configure your browser to use this server and port as its proxy
    >>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Cont
    roller
    Aug 13, 2010 5:42:27 PM net.sf.sahi.RemoteRequestProcessor processHttp
    Aug 13, 2010 5:43:18 PM net.sf.sahi.RemoteRequestProcessor processHttp

    Aug 13, 2010 5:43:30 PM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
    cation
    INFO: getRequestingProtocol() = http
    Aug 13, 2010 5:43:30 PM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
    cation
    INFO: realm=; getRequestingScheme()=basic
    Aug 13, 2010 5:43:30 PM net.sf.sahi.RemoteRequestProcessor process401
    INFO: wwwAuthenticate: Basic realm=""Client name UAT environment""
    Aug 13, 2010 5:43:30 PM net.sf.sahi.RemoteRequestProcessor process401
    INFO: scheme=basic; realm="Client name UAT environment"

    Thanks again for all your help
    Umesh
  • narayannarayan Administrators
    Hi Umesh,

    The double quotes are causing some problem.

    Here are two things you can try:

    1) Open sahi/htdocs/spr/401.htm
    2) Search for a setCredentials function
    3) Replace
    Sahi.prototype.setCredentials = function(){
        var authUser = document.authForm.authUser.value;
        var authPassword = document.authForm.authPassword.value;
    
        this.sendToServer("/_s_/dyn/SessionState_setCredentials?"+
                "authUser=" + encodeURIComponent(authUser) +
                "&authPassword=" + encodeURIComponent(authPassword) +
                "&authRealm=" + encodeURIComponent("$authKey"));
        location.reload();
    }
    
    with
    Sahi.prototype.setCredentials = function(){
        var authUser = document.authForm.authUser.value;
        var authPassword = document.authForm.authPassword.value;
    
        this.sendToServer("/_s_/dyn/SessionState_setCredentials?"+
                "authUser=" + encodeURIComponent(authUser) +
                "&authPassword=" + encodeURIComponent(authPassword) +
                "&authRealm=" + encodeURIComponent('$authKey')); // Single quote around $authKey
        location.reload();
    }
    
    4) Restart Sahi, clear browser cache and check again.

    5) If that does not work, in step 3, replace line
    "&authRealm=" + encodeURIComponent('$authKey')); // Single quote around $authKey
    
    with
    "&authRealm=''"; // set to blank. That is what seems to given by Java as the realm to match against.
    
    Restart Sahi, clear browser cache and check again.


    I think setting to blank as stated in step 5 should work for you.

    Regards,
    Narayan
  • Hi,

    I followed the above steps but did not solve my problem.
    Anyone have solution how to resolve the issue.

    The server trace is attached below


    C:\sahi\userdata\bin>SET SAHI_HOME=..\..

    C:\sahi\userdata\bin>SET SAHI_USERDATA_DIR=..

    C:\sahi\userdata\bin>SET SAHI_EXT_CLASS_PATH=

    C:\sahi\userdata\bin>CALL ..\..\bin\dashboard.bat
    SAHI_HOME: ..\..
    SAHI_USERDATA_DIR: ..
    SAHI_EXT_CLASS_PATH:
    Sahi properties file = C:\sahi\config\sahi.properties
    Sahi user properties file = C:\sahi\userdata\config\userdata.properties
    >>>> Sahi started. Listening on port: 9999
    >>>> Configure your browser to use this server and port as its proxy
    >>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Cont
    roller
    Reading browser types from: C:\sahi\userdata\config\browser_types.xml
    Firefox 4 was not found at C:\Program Files (x86)\Mozilla Firefox 4.0 Beta 7\fir
    efox.exe
    Firefox was not found at C:\Program Files (x86)\Mozilla Firefox\firefox.exe
    Safari was not found at C:\Program Files (x86)\Safari\Safari.exe
    Chrome was not found at $LOCALAPPDATA\Google\Chrome\Application\chrome.exe
    Opera was not found at C:\Program Files (x86)\Opera\opera.exe
    Jul 16, 2012 7:52:54 AM net.sf.sahi.ssl.SSLHelper getKeyManagerFactoryForRemoteF
    etch
    INFO: No SSL Client Cert specified
    >>>>>> Tests size = 1
    #### Running Script: C:\sahi\userdata\scripts\VV_DICOMAcceptanceTest_Prototype.s
    ah
    Jul 16, 2012 7:52:55 AM net.sf.sahi.test.ProcessHelper execute
    INFO: "C:\Program Files (x86)\Internet Explorer\iexplore.exe" -noframemerging "h
    ttp://sahi.example.com/_s_/dyn/Player_auto?startUrl=http%3A%2F%2F172.29.10.202%2
    Fvitrea-home%2Fauth%2Flogin__SahiAmpersandSahi__sahisid=sahi_ac70d51b086c4040460
    b17a0e1a941c3b1fcsahixb37e62380dcc104e3c08c0d0bb1ab7fc59b2x__SahiAmpersandSahi__
    isSingleSession=false"
    Jul 16, 2012 7:52:58 AM net.sf.sahi.test.ProcessHelper$PIDGatherer run
    INFO: PIDs: []; 2640 ms
    Jul 16, 2012 7:52:59 AM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
    cation
    INFO: getRequestingProtocol() = http
    Jul 16, 2012 7:52:59 AM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
    cation
    INFO: realm=vitrea-mint_BVT-2K8-VV; getRequestingScheme()=basic
    Jul 16, 2012 7:52:59 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: wwwAuthenticate: Basic realm="vitrea-mint_BVT-2K8-VV"
    Jul 16, 2012 7:52:59 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: scheme=basic; realm=vitrea-mint_BVT-2K8-VV
    Jul 16, 2012 7:53:20 AM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
    cation
    INFO: getRequestingProtocol() = http
    Jul 16, 2012 7:53:20 AM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
    cation
    INFO: realm=vitrea-mint_BVT-2K8-VV; getRequestingScheme()=basic
    Jul 16, 2012 7:53:20 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: wwwAuthenticate: Basic realm="vitrea-mint_BVT-2K8-VV"
    Jul 16, 2012 7:53:20 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: scheme=basic; realm=vitrea-mint_BVT-2K8-VV
    Jul 16, 2012 7:54:10 AM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
    cation
    INFO: getRequestingProtocol() = http
    Jul 16, 2012 7:54:10 AM net.sf.sahi.config.SahiAuthenticator getPasswordAuthenti
    cation
    INFO: realm=vitrea-mint_BVT-2K8-VV; getRequestingScheme()=basic
    Jul 16, 2012 7:54:10 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: wwwAuthenticate: Basic realm="vitrea-mint_BVT-2K8-VV"
    Jul 16, 2012 7:54:10 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: scheme=basic; realm=vitrea-mint_BVT-2K8-VV
    Killing C:\sahi\userdata\scripts\VV_DICOMAcceptanceTest_Prototype.sah
    Jul 16, 2012 7:54:11 AM net.sf.sahi.test.ProcessHelper kill
    INFO: Kill: []


    Thanks in advance.
    Niranjan
Sign In or Register to comment.