0
Grails 1.3.5并安装了selenium-rc,easyb和spring-security-core插件。除了我遇到的这种情况之外,一切看起来都很顺利。我有一个页面我正在测试哪个有以下标记:Grails + Selenium + EasyB + spring-security-core:ifAnyGranted不工作
<sec:ifAnyGranted roles='ROLE_ADMIN'>
<span class="menuButton">
<g:link mapping="adminPage">
<g:message code="default.admin.label" default="--Admin--"/>
</g:link>
</span>
</sec:ifAnyGranted>
当正常运行应用程序,一切工作正常。如果我以普通用户身份登录,则不显示Admin链接。如果我以管理员身份登录,则链接确实显示。在运行我的测试时,无论登录谁,检查都会失败,因此Admin链接永远不会呈现。
scenario "An Admin User logs into the system", {
when "the user completes the login form with proper credentials", {
grailsApplication = ApplicationHolder.application
springSecurityService = ApplicationHolder.application.mainContext.getBean("springSecurityService")
def userAdmin = new User(username: 'testAdmin', firstName: 'Test', lastName: 'Admin', enabled: true, password: springSecurityService.encodePassword("password")).save(flush: true)
def roleAdmin = new Role(authority: 'ROLE_ADMIN').save(flush: true)
UserRole.create(userAdmin, roleAdmin)
selenium.openAndWait("/platform/login/auth")
selenium.type('j_username', 'testAdmin')
selenium.type('j_password', 'password')
selenium.clickAndWait('signInBtn')
}
then "the user should be logged in and viewing their My Account page, as an admin", {
selenium.isTextPresent("Welcome Test").shouldBe true
selenium.isElementPresent('link=Admin').shouldBe true
}
}
其他标签的工作就好,如ifLoggedIn和ifNotLoggedIn。任何人都知道这是一个已知问题还是其他任何信息?谢谢。
这是它的亚伦。谢谢! – Gregg 2010-10-15 21:20:09