Lusar Blog

.NET Developer. Sitecore Consultant.

Smoke Test Sitecore Security Hardening

Add automated test on your CI to test how secure your Sitecore server

This are some test cases you can run as part of your integration tests on your CI

The script

Notice you can either set up the url on the app.config or on the environment settings which is useful if you want to dinamically change the url on for example, TeamCity.

Full Text Search in the Sitecore User Manager

How to be able to search by name, email and comments in the Sitecore User Manager

After googling on how to enhance the Sitecore User Manager, I bumped into Teach User Manager how to search by email and Search by Email in the Sitecore User Manager. However, that’s not good enough for me because you need to do exact match on the email address.

So what if we use Sitecore Content Search for this? After getting an example on Indexing an External Database in Sitecore 7, I decided to integrate both approches: Override the default UserProvider and DomainProvider to use Sitecore Content Search.

Create a custom crawler and use it on your custom user provider

Create a IndexedUser class

And use it on the IndexableUser

Create an user crawler

And override the default UserProvider

Finally, add your include config

Override the domain provider

Create a CustomDomain

And replace the Domains.config

This has been tested on Sitecore 8.1 Update 1.

NUnit Test Runner for Sitecore

A web-based nunit test runner for Sitecore CMS

Why

One of the techniques used for testing Sitecore is using embedded test runner. You can find more information in this book and some videos from codeflood.

Features

This test runner will allow you to run all nunit test on a test suite, but also filter by category, text fixture and run individual tests. It will also generate a TestResult.xml file based on the Nunit test result.

Settings

  • NUnitTestRunnerEnabled to enable/disable the test runner
  • NUnitTestRunnerRoute to set the route. The default route is testrunner and you should be able to access the test runner using your browser youhost/testnunner/
  • NUnitTestRunnerPath is the default path to the dll containing the tests, example ScBootstrap.Tests.dll asumming the dll is in the bin folder or a full path i.e C:\YourPath\NUnitContrib.Web.TestExamples.dll. This setting is mandatory
  • NUnitTestRunnerResultPath is the output file for the test result. The default value is TestResult.xml meaning that it will be saved on your bin folder. You can also provide a full path, i.e, C:\Temp\TestResult.xml. Please make sure the process has write access to that file.

Configuration file example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor type="NUnitContrib.Web.TestRunner.Pipelines.RunnerConfig, NUnitContrib.Web.TestRunner" />
      </initialize>
    </pipelines>
    <settings>
      <setting name="NUnitTestRunnerEnabled" value="true" />

      <setting name="NUnitTestRunnerRoute" value="testrunner"/>
      <!--<setting name="NUnitTestRunnerRoute" value="tests"/>-->

      <setting name="NUnitTestRunnerPath" value="ScBootstrap.Tests.dll"/>
      <!--<setting name="NUnitTestRunnerPath" value="C:\Projects\TestRunner\src\TestExamples\bin\Debug\NUnitContrib.Web.TestExamples.dll"/>-->

      <setting name="NUnitTestRunnerResultPath" value="TestResult.xml"/>
      <!--<setting name="NUnitTestRunnerResultPath" value="C:\Temp\TestResult.xml"/>-->
    </settings>
  </sitecore>
</configuration>

License and source code

Code licensed under the The MIT license and you can find the source code on github.