Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/utils/url.ts parseUrl does not recognize Authentication #1990

Closed
trendfischer opened this issue Apr 12, 2019 · 4 comments
Closed

src/utils/url.ts parseUrl does not recognize Authentication #1990

trendfischer opened this issue Apr 12, 2019 · 4 comments
Milestone

Comments

@trendfischer
Copy link

The method parseUrl does not recognize the authentication part in an URL like https://test:[email protected]/test/

As result, a parsed.host = "test:[email protected]" is returned resulting in a DNS failure using testcafe.

Expected would be a type ParsedUrl

{
    protocol: 'https',
    host: 'domain.tld',
    hostname: 'domain.tld',
    port: '',
    username: 'test',
    password: 'secret'
}

I found this error when I used testcafes user roles with http authentication in combination. The role initializer gets an URL with the authentication part. This outputs the cantResolveUrl message:

      Error details:
      Failed to find a DNS-record for the resource at

Hopefully this testcafe-hammerhead repo is the right place to fix this issue. If not, I would open an issue in the testcafe repo with a more generalized error report.

@Farfurix
Copy link
Contributor

@trendfischer

Hello.

If you use HTTP Basic or Windows (NTLM) authentication in your project, you need to use the approach described in HTTP Authentication.

I tried to run the following test using the HTTP Authentication, and it was successful:

import { Selector } from 'testcafe';

fixture `My Fixture`
    .page `http://www.httpwatch.com/httpgallery/authentication/`;

test
    .httpAuth({
        username: 'httpwatch',
        password: 'httpwatch123',
    })
    ('test', async (t) => {
    await t
        .click(Selector('#displayImage'))
        .debug();
});

@trendfischer
Copy link
Author

@Farfurix

Sorry, I fear "question" is the wrong tag for this ticket. My setup is like the following, in contrast to our internal servers, it works fine with httpbin:

/* global fixture, test */
import { Role } from 'testcafe';

const userRegular = Role(
    'https://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org%2Fbasic-auth%2Ftest%2Fsecret',
    async t => {
        await t
        // Do some login procedure
    }
);

fixture `My Fixture`
    .page `https://httpbin.org/status/200`
    .httpAuth({
        username: 'user',
        password: 'secret',
    })

test ('test', async (t) => {
    await t
        .useRole(userRegular)
        .navigateTo(`https://httpbin.org/status/200`)
        ;
});

The role "userRegular" is processing a cookie based authentication and returns a redirect. This works fine on a development machine. On our integration server called "preview", there is an HTTP authentication. If I login into the app with the cookie authentication combined with HTTP authentication, I get a response with a location header looking like this: http://172.29.64.146:33109/N97MeeYNL/https://user:secret@preview/admin

I do not know, if hammerhead, a used application library or our load balancer is responsible for the URL with the credentials, but the test fails with the described DNS failure message.

Since authentication in an URL is a common pattern, it would be nice if hammerhead would support it. And the source code looks like it would be no big change, since the returned type has already a username/password property. As a side effect, configuration between different test servers with and without http authentication would be easier to configure. So I would be grateful, if this ticket receives at least a "feature request".

@Farfurix
Copy link
Contributor

@thegreyt

Thank you for the additional details.
We have reproduced this issue. Our team will research it and check for a suitable solution.

LavrovArtem added a commit to LavrovArtem/testcafe-hammerhead that referenced this issue Apr 17, 2019
LavrovArtem added a commit to LavrovArtem/testcafe-hammerhead that referenced this issue Apr 18, 2019
@LavrovArtem LavrovArtem modified the milestones: Sprint #31, Sprint #32 Apr 22, 2019
@lock
Copy link

lock bot commented May 2, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked Issues that were automatically locked by the Lock bot label May 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants