How to write web performance tests for SharePoint Online and ADFS

Creating web performance tests in Visual Studio for SharePoint on premise is easy and well documented. But writing them for Office 365 / SharePoint online is another thing. The authentication can be different – depending on you configuration – and there is nearly no documentation available. In my case the SharePoint Online tenant authenticates via ADFS against a Windows Active Directory Domain.

The easiest way to get the authentication running is to record the authentication flow in Visual Studio. Before you start recording the web test, open your browser and make sure you are logged off from Office 365. Then record the login process to your site and edit the web test.

The first thing you have to do is to set your credentials for the test in the properties windows.

Set credentials for your web test

Now find the request to your adfs that ends in /adfs/ls/. Delete all the steps before that – you don’t need them. Remove the referrer and make the url to your adfs, the client request id and the user name context parameters. The extraction rule should be correct.

request adfs token

The next request you have to look for is a post to login.microsoft.com/login.srf. Delete all requests between the adfs and this one. Remove the referrer. The form post parameters should be correct – if not you have to adjust them according to the image.

Get access token from login.microsoft.com

The next thing we have to do is a post to /_forms/default.aspx on your SharePoint. This post will redirect you – so make sure to set the expected response url correctly. If you leave this step out you won’t get the authentication cookie!

Post to _forms default.aspx to get access cookie

Visual Studio will now add the cookie to every request. Delete all the other requests and add a new GET request to your desired page.

Request your sharepoint page

To make sure you don’t get redirected you should add a validation rule and validate something on your site. I added a rule and test the site title.

Add validation rule

If you run the test and encounter errors, check that the Set-Cookie ist set correctly after calling the login.srf. It must be in any request.

web test results for sharepoint online

I just started testing SharePoint Online and Office 365 for different customers. So expect more posts to this topic the next months. What’s your experience? Do you use automated tests for SharePoint online?

One comment

  1. Wow, I wonder why others haven’t written about this a lot!
    Thanks a lot Michael, highly appreciate this walkthrough.
    I do automated testing but this is something which I have never tried!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s