As far as I can see, it is necessary to have access to write in the machine key store. So how do I assign this permission to a user? I need to ask support people to grant a user the necessary permissions to run Moq, but I don’t know what exactly to ask for.
UPDATE: As Tim requested below, I’m updating with some information that might be useful to the problem understanding, as follows:
Apparently, Moq relies on Castle to build mock objects, and the Castle framework needs to write to machine key store. When I try to run the tests, the testing framework return the error “Unable to obtain public key for StrongNameKeyPair”.
When I went to support guys, they temporarily gave me administrative privileges, and everything ran as expected. Even after they removed the admin permissions, I was able to execute my tests.
My conclusion of this was that I need some permission to write on this machine key store. What I need to know is where exactly I need to have writing permissions, so I could ask support for a specific writing permission instead of admin permissions, for the other development environments, what would be denied for sure.
Thanks in advance!
After some research, I was able to find the exact directory I need to have write permission in order to execute Moq (in fact, it’s a Castle requirement). The user must have acces to the following folder:
C:\Documents and Settings\AllUsers\ApplicationData\Microsoft\Crypto\RSA\MachineKeys
(Assuming “C” is your system folder)
With this permission, the user running a mocking project with Moq won’t need admministrative privileges in the local machine. Here is a reference:
MVC Testing using a mocking framework (Moq)
Hope it helps.