Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally run tests that require admin privs #48

Open
GoogleCodeExporter opened this issue Jun 4, 2015 · 3 comments
Open

Conditionally run tests that require admin privs #48

GoogleCodeExporter opened this issue Jun 4, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

There are three tests now that fail due to access denied if you run them other 
than as admin.

Is there any way to:

1) Test for admin privs before running the test?
OR
2) Catch the access denied exception and issue a warning rather than a failure?

Original issue reported on code.google.com by arien.ma...@gmail.com on 2 Sep 2010 at 5:58

@GoogleCodeExporter
Copy link
Author

I think:

SecurityManager.IsGranted(new StorePermission(StorePermissionFlags.CreateStore))

would do it. I'll experiment, assigning to myself.

Original comment by arien.ma...@gmail.com on 2 Sep 2010 at 7:32

@GoogleCodeExporter
Copy link
Author

OK, that doesn't do it. I'm not sure the required security permission. The 
following code does make the error go away, but is sufficiently hinky that I'm 
not comfortable putting it in.


            try
            {
                AgentTester.EnsureStandardMachineStores();
            }
            catch (CryptographicException e)
            {
                if (e.Message.Trim() == "Access is denied.")
                {
                    // Don't have admin privs
                }
                else
                {
                    throw;
                }
            }


This post: 
http://www.ademiller.com/blogs/tech/2009/09/conditional-acceptance-tests-with-xu
nit-net/

Describes a method to conditionally not run tests, but I'm not an xunit expert 
and xunit itself is so poorly documented that I'm not sure how to put it into 
practice...

Original comment by arien.ma...@gmail.com on 2 Sep 2010 at 7:59

@GoogleCodeExporter
Copy link
Author

There are a number of good blogs out on xUnit - one of the best guys is located 
here

http://blog.benhall.me.uk/2008/01/introduction-to-xunit.html
http://blog.benhall.me.uk/2008/01/introduction-to-xunitnet-extensions.html
http://blog.benhall.me.uk/2008/01/creating-your-own-xunit-extension.html

I'll take a look at it. Also, there are samples that can be downloaded with the 
xunit installer (I did not include those in the external\xunit which could be 
beneficial in learning as well). If anything, I found that it is as least as 
well documented as NUnit and other test frameworks, but maybe I'm biased or 
indifferent ;)

Original comment by jtheisen...@gmail.com on 3 Sep 2010 at 4:23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant