07.11.2014 Views

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

114<br />

<strong>Enterprise</strong> <strong>Library</strong> <strong>Test</strong> <strong>Guide</strong><br />

<strong>Test</strong> case Result Automated test<br />

Verify that the<br />

AuthorizationRuleProvider<br />

object<br />

uses the rule in<br />

the configuration<br />

source to authorize<br />

Passed This test applies a rule named <strong>Test</strong>AnonymousRule that is defined<br />

in the configuration source. The test verifies that the AuthorizationRuleProvider<br />

object authorizes an anonymous identity.<br />

[<strong>Test</strong>Method]<br />

public void AuthorizeAnonymousIdentity<strong>Test</strong>()<br />

{<br />

an identity.<br />

AuthorizationRuleProvider authRuleProvider = AuthorizationFactory.GetAuthorizationProvider("DefaultRulePro<br />

vider") as AuthorizationRuleProvider;<br />

bool authorized = authRuleProvider.Authorize(new<br />

WindowsPrincipal(WindowsIdentity.GetAnonymous()),"<strong>Test</strong><br />

AnonymousRule");<br />

Assert.IsTrue(authorized);<br />

}<br />

Verify that the<br />

AzManAuthorizationProvider<br />

object uses<br />

the operations<br />

specified in the<br />

AzMan store to<br />

grant permission<br />

to an identity to<br />

perform a task.<br />

Passed<br />

This test verifies that an anyonymous identity has permission<br />

to view a purchase order. The purchase order is defined in the<br />

AzManFunc<strong>Test</strong>sConfig.xml AzMan store. The store grants permission<br />

to everyone to perform the View Purchase Order operation.<br />

The following is the information in the configuration file.<br />

<br />

<br />

<br />

The following is the test.<br />

[<strong>Test</strong>Method]<br />

public void AzManOperationAuthorize<strong>Test</strong>()<br />

{<br />

IAuthorizationProvider azManProvider = Authorization-<br />

Factory.GetAuthorizationProvider("DefaultAzManProvide<br />

r");<br />

WindowsIdentity identity = WindowsIdentity.GetAnonymous();<br />

bool isAuthorized = azManProvider.Authorize(new Window<br />

sPrincipal(identity), "O:View Purchase Order");<br />

Assert.IsTrue(isAuthorized);<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!