Monday, June 22, 2009

Feature testing in different sharepoint environment

Scenario:
Often in sharepoint we need to test a particular functionality with respect to different permission groups ( visitors / members / owners ) for testing.

Solution:
One common approach is to create multiple accounts for each type of access, but that eats up good amount of time switching back and forth.

So I wrote a quick script , which create 1 top level site and 3 more site collections for each type of access group.

Checkout the Urls in the script , you will understand what I meant by that. Idea is that same account will be in different permission group in different site collections. So you can switch permissions based on different urls.

Code:

@SET AdminAccount="training\administrator"
@SET AdminEmail="admin@training.com"
@SET SiteTemplate="STS#0"


Echo ==================================
@SET MAINSITEURL="http://localhost"

Echo Dropping the site collection
stsadm -o deletesite -url %MAINSITEURL%

Echo Recreating fresh site collection
stsadm -o createsite -url %MAINSITEURL% -sitetemplate %SiteTemplate% -ownerlogin %AdminAccount% -owneremail %AdminEmail% -title "Home"

Echo ==================================
@SET MAINSITEURL="http://localhost/sites/visitor"

Echo Dropping the site collection
stsadm -o deletesite -url %MAINSITEURL%

Echo Recreating fresh site collection
stsadm -o createsite -url %MAINSITEURL% -sitetemplate %SiteTemplate% -ownerlogin %AdminAccount% -owneremail %AdminEmail% -title "Visitors"

Echo ==================================
@SET MAINSITEURL="http://localhost/sites/members"

Echo Dropping the site collection
stsadm -o deletesite -url %MAINSITEURL%

Echo Recreating fresh site collection
stsadm -o createsite -url %MAINSITEURL% -sitetemplate %SiteTemplate% -ownerlogin %AdminAccount% -owneremail %AdminEmail% -title "Members"

Echo ==================================
@SET MAINSITEURL="http://localhost/sites/owners"

Echo Dropping the site collection
stsadm -o deletesite -url %MAINSITEURL%

Echo Recreating fresh site collection
stsadm -o createsite -url %MAINSITEURL% -sitetemplate %SiteTemplate% -ownerlogin %AdminAccount% -owneremail %AdminEmail% -title "Owners"

Echo ==================================
pause

0 comments: