473,769 Members | 4,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.S etClientCredent ial<UsernameTok en>(myCurrentTo ken);
adminServices.S etPolicy("Clien tPolicy");

The App.Config has

<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<configSections >
<section name="microsoft .web.services3"
type="Microsoft .Web.Services3. Configuration.W ebServicesConfi guration,
Microsoft.Web.S ervices3, Version=3.0.0.0 , Culture=neutral ,
PublicKeyToken= 31bf3856ad364e3 5" />
<sectionGroup name="applicati onSettings"
type="System.Co nfiguration.App licationSetting sGroup, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9" >
<section name="{ModuleNa mespace}.Proper ties.Settings"
type="System.Co nfiguration.Cli entSettingsSect ion, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
requirePermissi on="false" />
<section name="{ModuleNa mespace}.Proper ties.Settings"
type="System.Co nfiguration.Cli entSettingsSect ion, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
requirePermissi on="false" />
</sectionGroup>
</configSections>

<microsoft.web. services3>
<security>
<x509 allowTestRoot=" true" storeLocation=" CurrentUser" />
</security>
<tokenIssuer>
<statefulSecuri tyContextToken enabled="true" />
</tokenIssuer>
<messaging>
<mtom clientMode="On" />
</messaging>
<policy fileName="wse3p olicyCache.conf ig" />
</microsoft.web.s ervices3>

<applicationSet tings>
... [Web Reference]
</applicationSett ings>
</configuration>

and the wse3policyCache .config file has

<policies xmlns="http://schemas.microso ft.com/wse/2005/06/policy">
<extensions>
<extension name="usernameF orCertificateSe curity"
type="Microsoft .Web.Services3. Design.Username ForCertificateA ssertion,
Microsoft.Web.S ervices3, Version=3.0.0.0 , Culture=neutral ,
PublicKeyToken= 31bf3856ad364e3 5" />
<extension name="x509"
type="Microsoft .Web.Services3. Design.X509Toke nProvider,
Microsoft.Web.S ervices3, Version=3.0.0.0 , Culture=neutral ,
PublicKeyToken= 31bf3856ad364e3 5" />
<extension name="requireAc tionHeader"
type="Microsoft .Web.Services3. Design.RequireA ctionHeaderAsse rtion,
Microsoft.Web.S ervices3, Version=3.0.0.0 , Culture=neutral ,
PublicKeyToken= 31bf3856ad364e3 5" />
</extensions>
<policy name="ClientPol icy">
<usernameForCer tificateSecurit y establishSecuri tyContext="true "
renewExpiredSec urityContext="t rue"
requireSignatur eConfirmation=" false"
messageProtecti onOrder="SignBe foreEncrypt" requireDerivedK eys="true"
ttlInSeconds="3 00">
<serviceToken >
<x509 storeLocation=" CurrentUser" storeName="Addr essBook"
findValue="CN=W SE2QuickStartSe rver"
findType="FindB ySubjectDisting uishedName" />
</serviceToken>
<protection>
<request signatureOption s="IncludeAddre ssing,
IncludeTimestam p, IncludeSoapBody " encryptBody="tr ue" />
<response signatureOption s="IncludeAddre ssing,
IncludeTimestam p, IncludeSoapBody " encryptBody="tr ue" />
<fault signatureOption s="IncludeAddre ssing, IncludeTimestam p,
IncludeSoapBody " encryptBody="fa lse" />
</protection>
</usernameForCert ificateSecurity >
<requireActionH eader />
</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.Argument OutOfRangeExcep tion occurred
Message="Specif ied argument was out of the range of valid values.\r
\nParameter name: Policy 'ClientPolicy' is not configured in the
system"
Source="Microso ft.Web.Services 3"
ParamName="Poli cy '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.Configu ration" 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 3003
Anyone? Any wse experts out there?

On Jun 12, 3:32 pm, nyathan...@hotm ail.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.S etClientCredent ial<UsernameTok en>(myCurrentTo ken);
adminServices.S etPolicy("Clien tPolicy");

The App.Config has

<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<configSections >
<section name="microsoft .web.services3"
type="Microsoft .Web.Services3. Configuration.W ebServicesConfi guration,
Microsoft.Web.S ervices3, Version=3.0.0.0 , Culture=neutral ,
PublicKeyToken= 31bf3856ad364e3 5" />
<sectionGroup name="applicati onSettings"
type="System.Co nfiguration.App licationSetting sGroup, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9" >
<section name="{ModuleNa mespace}.Proper ties.Settings"
type="System.Co nfiguration.Cli entSettingsSect ion, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
requirePermissi on="false" />
<section name="{ModuleNa mespace}.Proper ties.Settings"
type="System.Co nfiguration.Cli entSettingsSect ion, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
requirePermissi on="false" />
</sectionGroup>
</configSections>

<microsoft.web. services3>
<security>
<x509 allowTestRoot=" true" storeLocation=" CurrentUser" />
</security>
<tokenIssuer>
<statefulSecuri tyContextToken enabled="true" />
</tokenIssuer>
<messaging>
<mtom clientMode="On" />
</messaging>
<policy fileName="wse3p olicyCache.conf ig" />
</microsoft.web.s ervices3>

<applicationSet tings>
... [Web Reference]
</applicationSett ings>
</configuration>

and the wse3policyCache .config file has

<policies xmlns="http://schemas.microso ft.com/wse/2005/06/policy">
<extensions>
<extension name="usernameF orCertificateSe curity"
type="Microsoft .Web.Services3. Design.Username ForCertificateA ssertion,
Microsoft.Web.S ervices3, Version=3.0.0.0 , Culture=neutral ,
PublicKeyToken= 31bf3856ad364e3 5" />
<extension name="x509"
type="Microsoft .Web.Services3. Design.X509Toke nProvider,
Microsoft.Web.S ervices3, Version=3.0.0.0 , Culture=neutral ,
PublicKeyToken= 31bf3856ad364e3 5" />
<extension name="requireAc tionHeader"
type="Microsoft .Web.Services3. Design.RequireA ctionHeaderAsse rtion,
Microsoft.Web.S ervices3, Version=3.0.0.0 , Culture=neutral ,
PublicKeyToken= 31bf3856ad364e3 5" />
</extensions>
<policy name="ClientPol icy">
<usernameForCer tificateSecurit y establishSecuri tyContext="true "
renewExpiredSec urityContext="t rue"
requireSignatur eConfirmation=" false"
messageProtecti onOrder="SignBe foreEncrypt" requireDerivedK eys="true"
ttlInSeconds="3 00">
<serviceToken >
<x509 storeLocation=" CurrentUser" storeName="Addr essBook"
findValue="CN=W SE2QuickStartSe rver"
findType="FindB ySubjectDisting uishedName" />
</serviceToken>
<protection>
<request signatureOption s="IncludeAddre ssing,
IncludeTimestam p, IncludeSoapBody " encryptBody="tr ue" />
<response signatureOption s="IncludeAddre ssing,
IncludeTimestam p, IncludeSoapBody " encryptBody="tr ue" />
<fault signatureOption s="IncludeAddre ssing, IncludeTimestam p,
IncludeSoapBody " encryptBody="fa lse" />
</protection>
</usernameForCert ificateSecurity >
<requireActionH eader />
</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.Argument OutOfRangeExcep tion occurred
Message="Specif ied argument was out of the range of valid values.\r
\nParameter name: Policy 'ClientPolicy' is not configured in the
system"
Source="Microso ft.Web.Services 3"
ParamName="Poli cy '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.Configu ration" 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
1776
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 with database if it returns right value or not. To do so, I need to save all inputs and results as development, debugging goes on.. But, NUnit doesn't seem to support it. and It require wrong Test coding.
3
1936
by: Finn J Johnsen | last post by:
Hi Dow do I get ndoc to ignore classes flagged with the attribute? Thanks, Finn Johnsen
1
1957
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 the following exception ( Only with the obfuscated assemblies ) : “Request for the permission of type System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.” I have...
1
2175
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
1803
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 seems to be the logical choice. Although it works well with very simple classes, it seems to struggle when you are confronted with anything substantial - eg an application that accesses/updates an RDBMS. For instance :-
20
2026
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. Hence can someone who has used them before share his/her experience on them so that I can get a better idea and make a proper choice ? Any link or suggestions are also welcome. Thanks and Regards, Parag
2
2434
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 Edition. In both VMs I downloaded and installed NUnit 2.2.8. In both VMs I commented out <startup> so that <supportedRuntime version="v2.0.50727"> is at at the top of the list. In both VMs NUnit doesn't work. It seems to ignore my and ...
1
2837
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 the product source code, but still want to execute them under nunit. I am trying this idea on nunit sample source code. Here is my class and the experiemental code: both money.cs and Imoney.cs is compiled to cs_money.dll. then I create another...
0
1244
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 help. Usually, I see examples of unit testings functions that take in 1-2 parameters and perform addition/multiplication/etc. I need to know how to unit test functions that return nothing, take in no parameters, and so on. For example, how do I...
0
9586
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.