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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7271bf8  SLING-12714 - Oidc Authentication Handler (#18)
7271bf8 is described below

commit 7271bf86f71cc9264c94ab7e09bd784b3640c97d
Author: Robert Munteanu <[email protected]>
AuthorDate: Tue Jun 3 15:04:09 2025 +0200

    SLING-12714 - Oidc Authentication Handler (#18)
    
    Minor test cleanups
---
 pom.xml                                            |  6 -----
 .../impl/SlingLoginCookieManagerTest.java          | 30 +++++-----------------
 2 files changed, 7 insertions(+), 29 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..a4c500d 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,16 +21,14 @@ 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;
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
-import java.io.IOException;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 import java.util.Base64;
@@ -51,39 +49,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 {
+    void setup() throws 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);
@@ -186,4 +170,4 @@ class SlingLoginCookieManagerTest {
         return cookie;
     }
 
-}
\ No newline at end of file
+}

Reply via email to