![](/img/trans.png)
[英]Spring Security requests basic authentication even though it's disabled (reactive)
以下 spring 安全配置提供了一些意外行為。 當在瀏覽器中向某些(非健康檢查)端點(/用戶)發出請求時以及使用 curl(通過 git bash 在 Windows 上)時,未經身份驗證的請求會按預期返回 idp 重定向。 但是,當使用 WebTestClient 時,它會返回401 Unau ...
[英]Spring Security requests basic authentication even though it's disabled (reactive)
以下 spring 安全配置提供了一些意外行為。 當在瀏覽器中向某些(非健康檢查)端點(/用戶)發出請求時以及使用 curl(通過 git bash 在 Windows 上)時,未經身份驗證的請求會按預期返回 idp 重定向。 但是,當使用 WebTestClient 時,它會返回401 Unau ...
[英]Change authorized user in tests
我想在一個測試中測試一組具有不同角色的用戶對方法的訪問。 我正在嘗試像這樣更改登錄用戶: 但無論我多么努力, perform(get (...))總是從ALL_ROLES_USERS數組中的第一個用戶開始執行。 從日志中可以看出: - 每次迭代都是同一個用戶! 知道為什么會這樣嗎? 也許perfo ...
[英]Getting 403 Forbidden for WebFluxTest in Oauth2 Secured (Client Credentials) Resource Server Application
我有一個反應式(Spring WebFlux)網絡應用程序,其中我有幾個 REST API,它們是受保護的資源。(Oauth2)。 要手動訪問它們,我需要獲取具有客戶端憑據授予類型的授權令牌並在請求中使用該令牌。 現在,我需要編寫可以通過 Spring 的 WebTestClient 調用來調用 A ...
[英]Spring Boot Test @PreAuthorize in a Library Module
我有一個使用 Spring Boot 1.5.21 編寫的庫模塊。 該庫有一個@Service ,其中一些方法用@PreAutorize注釋,只允許具有ADMIN權限的用戶執行某些操作,例如delete 。 然后我有一個使用該庫的 Spring 引導應用程序。 如果我運行該應用程序並手動測試它,它 ...
[英]Spring boot testing: User protected security controller on testing
這里有我的控制器方法: 如您所見,它使用@PreAuthorize("principal == '" + EspaiDocConstants.BO_COMPONENT_APP + "'") 這是我的測試代碼: 不過,我收到以下異常消息: DigestAuditsT ...
[英]Generate generate OAuth2 access token with additional claims to JUnit test
我有使用OAuth2保護的Spring Boot REST API。 我的身份驗證服務器和資源服務器是兩個應用程序。 所有REST API安全性均可與REST客戶端正常使用。 然后,我需要編寫安全測試用例。 我使用以下代碼生成訪問令牌。 一些端點需要在REST方法中手動添加聲明。 程 ...
[英]Spring boot OAuth2 test secured end-point given 200 status without token
我使用OAuth 2安全性開發帶有其余端點的Spring Boot Web應用程序。 所有端點在運行時均使用密碼grant_type正確保護。 但是帶有MockMvc的測試用例不考慮令牌。 它可以訪問沒有令牌的安全端點。 這是什么原因。 AuthorizationServe ...
[英]Is there a way to up only security context in Spring Boot tests?
我想寫一些依賴於Spring Security的單元測試。 例如,我有一些使用某些存儲庫並用@PreAuthorize批注標記的服務方法。 我可以使用Mockito模擬存儲庫,沒有問題。 我也可以通過@WithSecurityContext注釋來模擬安全上下文。 但是,當我運行測試時 ...
[英]Configuration of spring-security doesn't seem to be applied while testing
我已經使用相應的 xml 安全配置配置了一個獨立的 mockMvc,用於測試我用 @PreAuthorize(hasAnyRole('DM,CD')) 注釋的控制器。 但是我的測試結果總是 tatus 200,即使我打電話給一個角色不正確的用戶。 我相信我的 xml 配置遺漏了一些東西,但這只是一個 ...
[英]missing dependencies in latest spring security test
我需要解決以下代碼中提到的某些方法(狀態,jsonPath,內容)- 當我搜索包含這些方法的相關項目時,其中許多正在導入以下內容 問題是我無法在版本4.2.2的spring-security-test軟件包中找到對應的版本 可能有效但無效的最接近的選項是 上面沒有包 ...
[英]Gradle not downloading test dependency
我希望向我的使用 gradle 的項目添加測試依賴項。 我只需要讓 gradle 下載依賴 jar,這樣我就可以導入部分包。 我需要的是以下包: 所以我編輯了我的 gradle 文件以包含 進入這個后我嘗試構建項目。 不幸的是,這不起作用,我無法import org.springframew ...
[英]Spring Security Test and MockMvc supply null custom UserDetails parameter to REST Controller
我正在嘗試編寫一個集成測試,該測試訪問 REST 端點並獲取特定經過身份驗證的用戶(我在測試中設置的用戶)的數據。 我最初嘗試使用mockMvc = webAppContextSetup(wac).apply(springSecurity()).build() ,但始終失敗並出現BeanInstan ...
[英]Testing Spring Boot Security configuration
我已經做了一個非常簡單的演示應用程序來嘗試測試Spring Boot安全性。 這是我的應用程序配置 @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true) @SpringBootApplication publi ...
[英]Issue with a Spring integration test involving an entity with lazy collections
我正在嘗試新的Spring Security Test框架。 我有一個測試,涉及返回帶有延遲集合的JPA實體。 由於其中一個惰性集合,因此以下測試最終會出錯。 這是錯誤消息: 我在測試設置中出了什么問題? 為什么JPA實體經理過早關閉? 我該如何規避這個問題? ...