This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch issue/SLING-12714-cleanups
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-oauth-client.git

commit 7cc27f505e25eafee3df4a607bfb59c7789e34ac
Author: Robert Munteanu <[email protected]>
AuthorDate: Tue Jun 3 14:33:34 2025 +0200

    SLING-12714 - Oidc Authentication Handler
    
    Minor test cleanups
---
 pom.xml                                            |  6 ------
 .../impl/SlingLoginCookieManagerTest.java          | 25 +++++-----------------
 2 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/pom.xml b/pom.xml
index 7e93099..ecc9031 100644
--- a/pom.xml
+++ b/pom.xml
@@ -417,12 +417,6 @@
             <version>1.40.0</version>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr.annotations</artifactId>
-            <version>1.12.0</version>
-            <scope>provided</scope>
-        </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.resource</artifactId>
diff --git 
a/src/test/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManagerTest.java
 
b/src/test/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManagerTest.java
index d0caf4b..00c3e2a 100644
--- 
a/src/test/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManagerTest.java
+++ 
b/src/test/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManagerTest.java
@@ -21,10 +21,9 @@ import 
org.apache.sling.auth.oauth_client.spi.OidcAuthCredentials;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.resource.api.JcrResourceConstants;
 import org.jetbrains.annotations.NotNull;
-import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.io.TempDir;
 import org.osgi.framework.BundleContext;
 
 import javax.servlet.http.Cookie;
@@ -51,39 +50,25 @@ class SlingLoginCookieManagerTest {
     private final MockResponse response = new MockResponse();
     private final SlingRepository repository = mock(SlingRepository.class);
     private SlingLoginCookieManager slingLoginCookieManager;
-    private File tempFile;
+    private @TempDir File tempFolder;
 
     @BeforeEach
     void setup() throws IOException, NoSuchAlgorithmException, 
InvalidKeyException {
         SlingLoginCookieManager.SlingLoginCookieManagerConfig config = 
mock(SlingLoginCookieManager.SlingLoginCookieManagerConfig.class);
 
-        TemporaryFolder tempFolder = new TemporaryFolder();
-        tempFolder.create();
-        tempFile = tempFolder.newFile();
+        File tokenFile = new File(tempFolder, "cookie-tokens.bin");
 
-        when(config.tokenFile()).thenReturn(tempFile.getAbsolutePath());
+        when(config.tokenFile()).thenReturn(tokenFile.getAbsolutePath());
         when(config.form_token_fastseed()).thenReturn(false);
         when(config.sessionTimeout()).thenReturn(8 * 60 * 60 * 1000L);
         when(config.cookieName()).thenReturn(COOKIE_NAME);
 
         BundleContext bundleContext = mock(BundleContext.class);
-        when(bundleContext.getDataFile("cookie-tokens")).thenReturn(tempFile);
+        when(bundleContext.getDataFile("cookie-tokens")).thenReturn(tokenFile);
         
         slingLoginCookieManager = new SlingLoginCookieManager(config, 
bundleContext);
     }
 
-    @AfterEach
-    void tearDown() throws IOException {
-        // Clean up the temporary file created for the token store
-        if (tempFile.exists()) {
-            if (!tempFile.delete()) {
-                System.err.println("Error: Failed to delete temporary file: " 
+ tempFile.getAbsolutePath());
-            }
-        } else {
-            System.err.println("Error: Temporary file does not exist: " + 
tempFile.getAbsolutePath());
-        }
-    }
-    
     @Test
     void setGetVerifyLoginCookie() {
         OidcAuthCredentials creds = mock(OidcAuthCredentials.class);

Reply via email to