473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

SetPolicy Exception while using NUnit

Hi,
I am using WSE to implement security using x509 certificates. This
works when I use a windows client but throws an exception when I use
NUnit.

My Code looks as follows :
UsernameToken myCurrentToken = new UsernameToken("xxxx", "YYY",
PasswordOption.SendPlainText);
MyServicesWse adminServices = new MyServicesWse();

adminServices.SetClientCredential<UsernameToken>(m yCurrentToken);
adminServices.SetPolicy("ClientPolicy");

The App.Config has

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.web.services3"
type="Microsoft.Web.Services3.Configuration.WebSer vicesConfiguration,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGrou p, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="{ModuleNamespace}.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
<section name="{ModuleNamespace}.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>

<microsoft.web.services3>
<security>
<x509 allowTestRoot="true" storeLocation="CurrentUser" />
</security>
<tokenIssuer>
<statefulSecurityContextToken enabled="true" />
</tokenIssuer>
<messaging>
<mtom clientMode="On" />
</messaging>
<policy fileName="wse3policyCache.config" />
</microsoft.web.services3>

<applicationSettings>
... [Web Reference]
</applicationSettings>
</configuration>

and the wse3policyCache.config file has

<policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy">
<extensions>
<extension name="usernameForCertificateSecurity"
type="Microsoft.Web.Services3.Design.UsernameForCe rtificateAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
<extension name="x509"
type="Microsoft.Web.Services3.Design.X509TokenProv ider,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
<extension name="requireActionHeader"
type="Microsoft.Web.Services3.Design.RequireAction HeaderAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</extensions>
<policy name="ClientPolicy">
<usernameForCertificateSecurity establishSecurityContext="true"
renewExpiredSecurityContext="true"
requireSignatureConfirmation="false"
messageProtectionOrder="SignBeforeEncrypt" requireDerivedKeys="true"
ttlInSeconds="300">
<serviceToken>
<x509 storeLocation="CurrentUser" storeName="AddressBook"
findValue="CN=WSE2QuickStartServer"
findType="FindBySubjectDistinguishedName" />
</serviceToken>
<protection>
<request signatureOptions="IncludeAddressing,
IncludeTimestamp, IncludeSoapBody" encryptBody="true" />
<response signatureOptions="IncludeAddressing,
IncludeTimestamp, IncludeSoapBody" encryptBody="true" />
<fault signatureOptions="IncludeAddressing, IncludeTimestamp,
IncludeSoapBody" encryptBody="false" />
</protection>
</usernameForCertificateSecurity>
<requireActionHeader />
</policy>
</policies>

As I mentioned, this works when I use the windows client to access the
web service, but when I try to access the web service using NUnit, I
get the following exception :

System.ArgumentOutOfRangeException occurred
Message="Specified argument was out of the range of valid values.\r
\nParameter name: Policy 'ClientPolicy' is not configured in the
system"
Source="Microsoft.Web.Services3"
ParamName="Policy 'ClientPolicy' is not configured in the system"

This seems to imply that the system can't find or load the appropriate
config file. But I fail to see why. Both the files are present in the
project directory. I've also copied both the config files to the
directory where the Nunit project file (and the dlls being tested) are
present. I've also tried copying it to the directory where the
NUnit.exe itself is located, but it doesn't make any difference. I've
added references to both "Microsoft.Web.Services3" and
"System.Configuration" modules in both my projects (windows client,
NUnit test class).

Any help regarding this would be much appreciated. Is there something
I am doing wrong/missing here or is this an inherent problem with
NUnit?

Thanks in advance.

Jun 12 '07 #1
1 2973
Anyone? Any wse experts out there?

On Jun 12, 3:32 pm, nyathan...@hotmail.com wrote:
Hi,
I am using WSE to implement security using x509 certificates. This
works when I use a windows client but throws an exception when I use
NUnit.

My Code looks as follows :
UsernameToken myCurrentToken = new UsernameToken("xxxx", "YYY",
PasswordOption.SendPlainText);
MyServicesWse adminServices = new MyServicesWse();

adminServices.SetClientCredential<UsernameToken>(m yCurrentToken);
adminServices.SetPolicy("ClientPolicy");

The App.Config has

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.web.services3"
type="Microsoft.Web.Services3.Configuration.WebSer vicesConfiguration,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGrou p, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="{ModuleNamespace}.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
<section name="{ModuleNamespace}.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>

<microsoft.web.services3>
<security>
<x509 allowTestRoot="true" storeLocation="CurrentUser" />
</security>
<tokenIssuer>
<statefulSecurityContextToken enabled="true" />
</tokenIssuer>
<messaging>
<mtom clientMode="On" />
</messaging>
<policy fileName="wse3policyCache.config" />
</microsoft.web.services3>

<applicationSettings>
... [Web Reference]
</applicationSettings>
</configuration>

and the wse3policyCache.config file has

<policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy">
<extensions>
<extension name="usernameForCertificateSecurity"
type="Microsoft.Web.Services3.Design.UsernameForCe rtificateAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
<extension name="x509"
type="Microsoft.Web.Services3.Design.X509TokenProv ider,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
<extension name="requireActionHeader"
type="Microsoft.Web.Services3.Design.RequireAction HeaderAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</extensions>
<policy name="ClientPolicy">
<usernameForCertificateSecurity establishSecurityContext="true"
renewExpiredSecurityContext="true"
requireSignatureConfirmation="false"
messageProtectionOrder="SignBeforeEncrypt" requireDerivedKeys="true"
ttlInSeconds="300">
<serviceToken>
<x509 storeLocation="CurrentUser" storeName="AddressBook"
findValue="CN=WSE2QuickStartServer"
findType="FindBySubjectDistinguishedName" />
</serviceToken>
<protection>
<request signatureOptions="IncludeAddressing,
IncludeTimestamp, IncludeSoapBody" encryptBody="true" />
<response signatureOptions="IncludeAddressing,
IncludeTimestamp, IncludeSoapBody" encryptBody="true" />
<fault signatureOptions="IncludeAddressing, IncludeTimestamp,
IncludeSoapBody" encryptBody="false" />
</protection>
</usernameForCertificateSecurity>
<requireActionHeader />
</policy>
</policies>

As I mentioned, this works when I use the windows client to access the
web service, but when I try to access the web service using NUnit, I
get the following exception :

System.ArgumentOutOfRangeException occurred
Message="Specified argument was out of the range of valid values.\r
\nParameter name: Policy 'ClientPolicy' is not configured in the
system"
Source="Microsoft.Web.Services3"
ParamName="Policy 'ClientPolicy' is not configured in the system"

This seems to imply that the system can't find or load the appropriate
config file. But I fail to see why. Both the files are present in the
project directory. I've also copied both the config files to the
directory where the Nunit project file (and the dlls being tested) are
present. I've also tried copying it to the directory where the
NUnit.exe itself is located, but it doesn't make any difference. I've
added references to both "Microsoft.Web.Services3" and
"System.Configuration" modules in both my projects (windows client,
NUnit test class).

Any help regarding this would be much appreciated. Is there something
I am doing wrong/missing here or is this an inherent problem with
NUnit?

Thanks in advance.

Jun 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sky Kim | last post by:
Hi, all. I've know NUnit for a while, now I try to use it. Most of application I develope is data base driven. I want to test data layer most with may input and checking the result, then compare...
3
by: Finn J Johnsen | last post by:
Hi Dow do I get ndoc to ignore classes flagged with the attribute? Thanks, Finn Johnsen
1
by: Nadav | last post by:
Hi, I am writing an Obfuscator to Obfuscate managed .NET assemblies, the obfuscator works with most of the assemblies I have tried, how ever, some assemblies ( such as nunit-gui.exe ) generate...
1
by: Justin D. Fisher | last post by:
Anyone out there use NUnit for unit level testing on VB.Net? I see lots of C# documentation out there but very little for VB.Net? Can anyone suggest some books or web sites that address this?
1
by: MD | last post by:
Hello I work in a .NET environment and I am about to create a development strategy. As part of this I am looking at implementing a testing tool to fit in with an iterative approach and NUnit...
20
by: Parag | last post by:
Hi, I am trying to figure out best testing tool for my project. I have narrowed down my requirements to two tools NUNIT and VSTS unit. But I have used neither and I have to use only one of them....
2
by: Mark Jerde | last post by:
I'm pulling my hair out here.... Trying to get a simple NUnit project working. I just created two new virtual machines in Virtual PC, one with VS 2005 Pro and the other with Visual C# Express...
1
by: learning | last post by:
Hi how can I instaltiate a class and call its method. the class has non default constructor. all examples i see only with class of defatul constructor. I am trying to pull the unit test out from...
0
by: noway001 | last post by:
Hi, I need to learn how to do unit tests for certain functions. I have googled and come accross some stuff, but all the examples are easy. I read multiple articles on code project, but it didn't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.