我很久以前是一名开发人员,负责我们的团队为我们的web应用程序使用Selenium和C#进行自动化测试;我们的应用程序有许多用户可以扮演的角色,比如管理员、运营商、超级用户等等。根据所分配的角色,确定您在应用程序中具有的访问权限。
管理员可以访问所有页面等。运营商只能看到按钮x和y;并且只能看到菜单选项A、B和C。
用户必须进行身份验证。我很难想象出创建测试/用户的最佳方法。几乎所有的自动化测试都需要为每个用户角色运行。(我们实际上有4或5个不同的角色类型,每个角色类型对应用程序的各个部分有不同的访问权限)
怎样才能最好地处理这件事?有谁有我能看到的例子(我是一个视觉学习者)?
我并不试图同时测试是否有多个用户登录;我正在尝试测试应用程序中给定的个人管理设置--当他们登录并进行身份验证时,它将获取他们的登录信息,并获得他们的角色,然后应用程序会处理他们可以访问和不能访问的内容。(我也使用页面对象模型)
发布于 2020-04-02 06:21:11
您可以使用每个角色所需的有效负载对用户创建端点进行调用,然后使用新创建的用户的令牌访问系统。
或者,您可以在部署时创建具有特定功能的用户,例如使用数据库夹具,并在自动检查中使用这些预定义的用户。
发布于 2020-04-03 16:23:08
我现在正处于这种精确的测试中。Web应用程序很难正确地测试授权。数据设置可能很困难,因为您需要创建任意用户,并为他们分配角色。您还需要测试您的“标准”角色。每个HTTP请求、按钮和图标都需要测试“愉快”路径和“不开心”路径。
每个链接、每个页面的几个场景大纲都会工作。另外,每个网页都有几个场景大纲,模拟一个已经标记了该页面链接的人。
Scenario Outline: Authorized users can see the edit blog post link
Given a blog post exists
And a user exists with the "<Role>" role
When the user views the blog post
Then the "Edit Blog Post" link should be visible
Examples:
| Role |
| Admin |
| Power User |
Scenario Outline: Unauthorized users cannot see the edit blog post link
Given a blog post exists
And a user exists with the "<Role>" role
When the user views the blog post
Then the "Edit Blog Post" link should not be visible
Examples:
| Role |
| Carrier |
| Advertiser |例如,您基本上需要在具有编辑博客帖子链接的每一种页面上重复此测试。您还想防止人们深入链接或书签页面:
Scenario Outline: Authorized users can get to the edit blog post page
Given a blog post exists
And a user exists with the "<Role>" role
When the user edits the blog post
Then the user should be allowed access
Examples:
| Role |
| Admin |
| Power User |
Scenario Outline: Unauthorized users cannot go to the edit blog post page
Given a blog post exists
And a user exists with the "<Role>" role
When the user edits the blog post
Then the user should be denied access
Examples:
| Role |
| Carrier |
| Advertiser |您还应该防止在加载页面之后被撤销的角色,然后提交表单:
Scenario Outline: Authorized users cannot save blog posts after access is revoked
Given a blog post exists
And a user exists with the "<Role>" role
When the user edits the blog post
And the user has the "<Role>" role revoked
And the user saves the blog post
Then the user should be denied access
Examples:
| Role |
| Admin |
| Power User |深入研究这样的场景会迫使您考虑人们可以尝试规避权限检查的所有方法。这暴露了在系统上强制执行安全性的真正成本。当我第一次开始用这种方式进行测试时,我的脑子里有些不舒服。强制权限的成本比我预期的要高得多,但阐明测试用例场景也是成本的好理由。它迫使企业主意识到这种测试是多么的重要和大。
发布于 2023-04-21 11:48:04
问题:
我正在寻找完全相同的情况与不同的期望。我正在使用Spec流程框架进行自动化,我在过去使用过示例。但是在那里,对于所有用户来说,有一个行为相同的测试用例,它一个接一个地运行,但是测试步骤对于所有4个用户都是一样的。
类似地,是否可以为6个不同角色编写测试用例,其中每个角色在测试步骤中都有不同的期望。
https://sqa.stackexchange.com/questions/44133
复制相似问题