1

I'm using Selenium to Unit Test an Azure AD application in ASP.NET Core MVC web app and I am looking for a better method of logging in the test user besides searching the DOM for login input elements. I'm Unit Testing in Azure DevOps so logging in with the browser UI is not an option. Any ideas?

1 Answer 1

2

In OAuth based technologies it is not easy to get a token as a user without an interactive redirect. For automated test purposes the simplest option is often to use the Resource Owner Password Grant. This is not recommended for production usage in real UIs though.

Sign up to request clarification or add additional context in comments.

3 Comments

I did not know Microsoft even allowed that. I was able to get this working in conjunction with a client_secret to acquire the Access Token and ID Token. Now how can I get this into the cookie?
Ah - I was assuming you were using a token based Web UI in which case my suggestion would work well for testing. Cookie based apps come with lots of hidden complexity and this is only one aspect. You will need to act like a real browser and simulate posting DOM element values if you need cookies to call APIs.
That's what I'm doing now, and it's quite painful. I'll just leave it at that then, as I don't want to switch to storing tokens on the client just to make unit testing easier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.