黄瓜网测试 - 捕获vaules(Cucumber web testing - capture vaules)
我需要自动化注册表单并创建一个新帐户,然后使用相同的帐户详细信息登录新创建的帐号和密码。我需要在一个场景中执行此操作。
功能:创建新用户并捕获用户名,密码并尝试使用这些详细信息登录。
Scenario: test Given I am on xyz.com When I click on register Then I will enter required details for registration Then I will click on submit And I will enter new account details to login to test.
I need to automate a registration form and create a new account and then use the same account details to login with newly created account number and password.I need to do this in one scenario.
Feature: create new user and capture the username, password and try to login with those details.
Scenario: test Given I am on xyz.com When I click on register Then I will enter required details for registration Then I will click on submit And I will enter new account details to login to test.
原文:https://stackoverflow.com/questions/37621199
更新时间:2023-06-18 15:06
最满意答案
这应该工作:
让UserDetails在
getAuthorities()
返回一个空集合:public class User implements UserDetails { ... @Override public Collection<? extends GrantedAuthority> getAuthorities() { return new HashSet<GrantedAuthority>(); } }
在配置安全性时使用
authenticated()
http.authorizeRequests() ... .antMatchers("/foo").authenticated() ...
This should work:
Let UserDetails return an empty collection in
getAuthorities()
:public class User implements UserDetails { ... @Override public Collection<? extends GrantedAuthority> getAuthorities() { return new HashSet<GrantedAuthority>(); } }
Use just
authenticated()
while configuring securityhttp.authorizeRequests() ... .antMatchers("/foo").authenticated() ...
相关问答
更多-
'UserRole'未声明。('UserRole' is not declared. It may be inaccessible due to its protection level)[2023-04-16]
我假设您从数据库中提取UserRole 。 您收到此错误,因为尚未声明该变量。 我会提取该信息(用户的角色)并将其存储到名为UserRole的类级变量中。 然后,您将能够在Button1_Click子中访问它。 Public Class Form1 Dim loginerror As String Dim UserRole As String Public Function login() Dim DBconn As New ADODB.Connection Dim user As New ADODB.Re ... -
这应该工作: 让UserDetails在getAuthorities()返回一个空集合: public class User implements UserDetails { ... @Override public Collection extends GrantedAuthority> getAuthorities() { return new HashSet
(); } } 在配置安全性时使用aut ... -
而不是#sportName.toUpper()你需要使用类似#sport.name.toUpper()东西,因为#... @PreAuthorize变量引用方法参数: @RequestMapping(...) @PreAuthorize("hasRole(#sport.name.toUpper() + '_USER')") public String index(@PathVariable("sportName") Sport sport, Model model) { ... } 也可以看看: 15. ...
-
如何在弹簧安全性的代码中获取用户的授权凭证?(How to get user's authorization credentials in code with spring security?)[2022-06-29]
简单。 Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String username = auth.getName(); Object credentials = auth.getCredentials(); 要访问凭据 (即密码),您需要将erase-credentials设置为false :你不需要UserRole实体。 EF可以通过在没有该实体的情况下在数据库中创建适当的链接表来自动管理多对多关系。 最简单的解决方案就是将两个集合添加到您的User和Role实体。 EF将按照惯例检测多对多关系,无需进一步明确配置: public class User { public int UserId { get; set; } public string Username { get; set; } public string Password { get; set; } ...您可以使用name()方法而不是value() 。 如果您的应用中有固定的角色列表,您也可以在加载用户时映射到他们,如本答案中所述 。 You can use the name() method instead of value(). If you have a fixed list of roles in your app, you can also map to them when loading the user, as described in this answer.我似乎无法在线查找架构,但有更多可能的交叉引用表将显示那些角色中的用户。 您用作GetData([Control("RolesDropDown")] string Id)参数GetData([Control("RolesDropDown")] string Id)的语法对我来说是新的。 我从未见过这个。 但是,如果那是您希望过滤的ROLE的ID,那么您将在下面的查询中使用它。 我会使用RolesDropDown.SelectedValue从下拉列表中获取值 public IQueryable... 首先澄清术语:通常由Spring Security中的角色组成的权限是应用程序范围的权限。 另一方面, ACL (访问控制列表)指定特定域对象的权限。 就像你了解差异一样。 AD通常包含权限/角色,但不包含ACL。 如果您不想使用AD中的权限,您可以自己实现UserDetailsContextMapper并将其注入您的ActiveDirectoryLdapAuthenticationProvider实例中。 请参阅Spring Security参考文档,了解如何指定自定义身份验证提供程序。 如果要使用引用模 ...这里有2个陷阱。 第一个是当使用hasRole('ADMIN') ,如果它以角色前缀(默认为ROLE_ )开始,则首先进行检查,否则传入的角色是前缀(参见参考指南 ) 。 因此,在这种情况下,检查的实际权限是ROLE_ADMIN而不是您期望/假设的ADMIN 。 第二个是当使用in memory选项时, roles方法与此处提到的相同。 它检查传入的角色是否以角色前缀开头,如果没有,则添加它。 因此,在具有内存的示例中,您最终会获得权限ROLE_ADMIN和ROLE_DBA 。 但是,在JDBC选项中,您具 ...相关文章
更多- 《领测软件测试网软件测试公开课》(Course of Software Testing)[MP4]
- Beware the Web Fads of Yesteryear
- web storm使用和配置
- Shiro整合到Web应用
- Web Service PHP入门示例
- Web scraper open source
- HTML5 web存储(Web Storage)【HTML5教程 - 第十一篇】
- (转)Python WEB应用框架纵览
- [DAL]Web2py DAL与Postgres
- Web Services 三种基本的元素介绍
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。