1

I am working on a project where I am trying to test if a user has successfully logged in with valid credentials using the Microsoft.SharePoint.Client.dll.

Currently my code is checking the HTTP Response code for the SharePoint URL - however it is not checking to see if the user has passed in valid credentials.

For example - I can change my password, and the test will still pass since the code is only seeing if it is being passed a valid endpoint.

Is there a way with the Microsoft.SharePoint.Client.dll to see if a user has provided proper credentials?

Current Test

    [TestMethod]
    public void ConnectionToSharePoint_IsSuccessful()
    {
        var sharePointConnection = _sharePointService.OpenConnectionToSharePoint();
        var webRequest = (HttpWebRequest) WebRequest
            .Create(sharePointConnection.Url);
        var responce = (HttpWebResponse) webRequest.GetResponse();

        Assert.AreEqual(HttpStatusCode.OK,responce.StatusCode);
    }

2 Answers 2

0

You should look for Response Code. 401 means UnAuthorized and 403 means Forbidden.

0

If autentication is Form Based, onwrong credientals you will just be transfered on another page with error message or stay on the same page with http:200. You would need to check for particular html objects in the DOM as well.

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.