2010-10-15 98 views
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。任何人都知道這是一個已知問題還是其他任何信息?謝謝。

回答