Running tests in medium trust

15 views
Skip to first unread message

Krzysztof Koźmic (2)

unread,
Oct 6, 2009, 7:50:44 AM10/6/09
to NUnit-Discuss
I'm one of developers on Castle project, and recently an issue came up
about running our test suite in Medium Trust to catch early cases
where our code would break in sandbox scenarios.

I found some pointers on how to run assembly with restricted
permissionset
http://blogs.msdn.com/shawnfa/archive/2004/11/02/251239.aspx
and now I'm thinking enabling NUnit to take advantage of that.

Does NUnit have a plugin model that we could use for this?
How would you recommend to approach this task?

Charlie Poole

unread,
Oct 6, 2009, 8:15:10 AM10/6/09
to nunit-...@googlegroups.com
NUnit doesn't currently have anyplace to plug in at that level,
so you'd have to modify the code directly to get started. That's
what I'd do at first as a proof of concept. We could invent a
new extension point for it once we knew it could work.

The biggest issue is that NUnit can't work at all without
pretty strong permission set. For example you'd have to
allow reflection or we couldn't recognize tests.

If you want to experiment with this, the place to start is
the DomainManager service in the nunit.util project.

Charlie

Richard Howells

unread,
Oct 6, 2009, 8:34:35 AM10/6/09
to nunit-...@googlegroups.com
OK - Full disclosure - I have never tried this...

ISTM that you ought to be able to configure .Net so that all code loaded
from the folder where your tests reside run in a constrained trust
environment. You would do something like, create a new security policy in
.Net Configuration and have it apply to all assemblies loaded from <where
your test code lives>

Cheers,

Richard

ric...@dynamisys.co.uk
www.dynamisys.co.uk
(L) 01793 731225
(M) 07732 971786
Dynamisys is registered in the UK - number 4152561
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.420 / Virus Database: 270.14.3/2413 - Release Date: 10/05/09
18:23:00

Charlie Poole

unread,
Oct 6, 2009, 8:53:25 AM10/6/09
to nunit-...@googlegroups.com
Hi Richard,

Clever idea - no code mods!

If someone tries this with NUnit, please let us know what happens.
Reply all
Reply to author
Forward
0 new messages