Share via


Using Debug Permissions to Test Code

In this lesson, you will learn how to test your permissions code by using debug permissions. Debug permissions let you simulate what an end user will see, based on their role and permissions.

Using Debug Permissions

In the previous lesson, you wrote code to check permissions for viewing the Products screen. A permission is assigned to a role by the administrator of the application. To test your code, you want to run the application as both a user who has the permission and a user who does not. You can do so by setting debug permissions that let you run as a user with those permissions while testing or debugging the application.

To set debug permissions

  1. In Solution Explorer, double-click the Properties node.

    The Application Designer appears.

  2. Click the Access Control tab.

  3. In the Define permissions or select permissions to use for debugging grid, select the Can_View_Products permission, and select the Granted for debug check box.

  4. Press F5 to run the application.

    The Products menu should appear in the navigation menu under the Product Information group.

  5. Click the Close button in the upper-right corner of the running application to return to design mode.

  6. Select the Can_View_Products permission, and clear the Granted for debug check box.

  7. Press F5 to run the application again.

    You should not see the Products menu or the Product Information group. You are running the application without the necessary Can_View_Products permission.

Closer Look

In this lesson, you learned how to set debug permissions and test your application. Debug permissions let you run the application and simulate what an end user will see, based on their role and permissions. Without this capability you would have to create various user identities, close the application, and then log back on using a different identity.

In this example, only one permission was defined. Many applications will create multiple permissions for multiple purposes; you can select multiple debug permissions to test different combinations and make sure that your application works as you intended.

Next Steps

In the next set of lessons you will learn how to deploy, install, and administer your application.

Next lesson: Distributing Your Application

See Also

Tasks

How to: Create a Role-based Application

Other Resources

Enabling Authorization and Creating Permissions

Managing Settings in LightSwitch