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

Access a page under basic Auth #76

Closed
kabomi opened this issue Apr 20, 2022 · 6 comments
Closed

Access a page under basic Auth #76

kabomi opened this issue Apr 20, 2022 · 6 comments

Comments

@kabomi
Copy link

kabomi commented Apr 20, 2022

Hi all,

I need to access a page that's behind basic auth. So I have to set httpAuth credentials probably at fixture level

But, I couldn't find a command line argument that I could pass on for that purpose.
Any ideas on how can I set the httpAuth credentials?

In the meantime, I'm going to give it a try with a proxy configuration

Cheers

@Arthy000
Copy link
Owner

Hi @kabomi
I'm very sorry about the long delay (regarding your other ticket that you closed), I was travelling abroad and wasn't really paying attention to my emails.

I could easily add the ability to use command line to authenticate, something like

--username <string> --password <string> [--domain <string> [--workstation <string>]]

However, that would make writing your command line pretty annoying (even if you only use the mandatory ones).
So a better option is to use a configuration file in your repo, and on my side create a single command line parameter

--useHttpAuth

The only thing that's left is figure out how to attach the credentials to a specific feature (to match normal TestCafe behavior).
ATM the only idea I got is to create a JSON file like:

[
  "features": ["name1", "name2"],
  "username": "your username",
  "password": "your password",
  "domain": "your domain, can be undefined",
  "workstation": "your workstation, can be undefined"
]

But this could also be a pain to maintain if you have many features or many credentials.

What do you think?

@kabomi
Copy link
Author

kabomi commented May 11, 2022

Hi @Arthy000
Now I have to apologize too, sorry my lack of response!

My use case is: A fixture with only one set of credentials, other fixtures that does not need them.
So, your idea with the json file would be sufficient.

Another idea could be to generate a file for every .feature file that needs credentials, like:

  • For a file named stage.feature creating a file with name stage.credentials or stage.feature.credentials
  • If possible, the file/s instead of type .json could be .js or .ts, so that it could read the property values from ENV variables (process.env)

Any of the solutions would work for me! Thank you!

@Arthy000
Copy link
Owner

Hi @kabomi

I like that file idea, I'll try it tomorrow but I think it shouldn't be too hard

Arthy000 added a commit that referenced this issue May 15, 2022
http basic authentication can be used by creating a js file that contains the necessary credentials
(as seen in testcafe documentation) => featureFileName.credentials.js

re #76
@Arthy000
Copy link
Owner

@kabomi just pushed a branch with the changes as discussed. You can check the example I added. I'll leave you a few days to try it if you want. Merge and publish are coming but I still need to write some documentation :D

@kabomi
Copy link
Author

kabomi commented May 16, 2022

Cool @Arthy000 I will test it and give you feedback. Awesome!

@kabomi
Copy link
Author

kabomi commented May 23, 2022

Hey @Arthy000,
I had some holidays last week. I'd test it and IMO it works perfectly. Thanks for your efforts!

Arthy000 added a commit that referenced this issue May 24, 2022
http basic authentication can be used by creating a js file that contains the necessary credentials
(as seen in testcafe documentation) => featureFileName.credentials.js

re #76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants