From 447f4125ba18bac57ecb15feb687ab2389ff2c81 Mon Sep 17 00:00:00 2001
From: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date: Fri, 21 Jun 2024 08:47:13 +0000
Subject: [PATCH] Update to Keycloak 25.0.1

---
 src/test/java/org/keycloak/protocol/cas/ContentTypeHelperTest.java |   46 ++++++++++++++--------------------------------
 1 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/src/test/java/org/keycloak/protocol/cas/ContentTypeHelperTest.java b/src/test/java/org/keycloak/protocol/cas/ContentTypeHelperTest.java
index c08ab47..bdd024a 100644
--- a/src/test/java/org/keycloak/protocol/cas/ContentTypeHelperTest.java
+++ b/src/test/java/org/keycloak/protocol/cas/ContentTypeHelperTest.java
@@ -1,45 +1,27 @@
 package org.keycloak.protocol.cas;
 
-import org.jboss.resteasy.mock.MockHttpRequest;
-import org.jboss.resteasy.mock.MockHttpResponse;
-import org.jboss.resteasy.specimpl.RequestImpl;
+import jakarta.ws.rs.core.*;
 import org.junit.Test;
 import org.keycloak.protocol.cas.utils.ContentTypeHelper;
 
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-
 import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.*;
 
 public class ContentTypeHelperTest {
     @Test
-    public void test() throws Exception {
-        assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/", null).selectResponseType());
-        assertEquals(MediaType.APPLICATION_JSON_TYPE, get("http://example.com/?format=json", null).selectResponseType());
-        assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/?format=xml", null).selectResponseType());
-        assertEquals(MediaType.APPLICATION_JSON_TYPE, get("http://example.com/?format=JSON", null).selectResponseType());
-        assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/?format=XML", null).selectResponseType());
-
-        assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/", MediaType.APPLICATION_XML).selectResponseType());
-        assertEquals(MediaType.APPLICATION_JSON_TYPE, get("http://example.com/?format=json", MediaType.APPLICATION_XML).selectResponseType());
-        assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/?format=xml", MediaType.APPLICATION_XML).selectResponseType());
-
-        assertEquals(MediaType.APPLICATION_JSON_TYPE, get("http://example.com/", MediaType.APPLICATION_JSON).selectResponseType());
-        assertEquals(MediaType.APPLICATION_JSON_TYPE, get("http://example.com/?format=json", MediaType.APPLICATION_JSON).selectResponseType());
-        assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/?format=xml", MediaType.APPLICATION_JSON).selectResponseType());
-
-        assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/", MediaType.TEXT_PLAIN).selectResponseType());
+    public void test() {
+        assertEquals(MediaType.APPLICATION_XML_TYPE, get("").selectResponseType());
+        assertEquals(MediaType.APPLICATION_JSON_TYPE, get("json").selectResponseType());
+        assertEquals(MediaType.APPLICATION_XML_TYPE, get("xml").selectResponseType());
+        assertEquals(MediaType.APPLICATION_JSON_TYPE, get("JSON").selectResponseType());
+        assertEquals(MediaType.APPLICATION_XML_TYPE, get("XML").selectResponseType());
     }
 
-    private ContentTypeHelper get(String uri, String acceptHeader) throws Exception {
-        MockHttpRequest req = MockHttpRequest.get(uri);
-        MockHttpResponse res = new MockHttpResponse();
-        RequestImpl restReq = new RequestImpl(req, res);
-
-        if (acceptHeader != null) {
-            req = req.header(HttpHeaders.ACCEPT, acceptHeader);
-        }
-
-        return new ContentTypeHelper(req, restReq, req.getUri());
+    private ContentTypeHelper get(String format) {
+        MultivaluedHashMap<String,String> queryParams = mock(MultivaluedHashMap.class);
+        when(queryParams.getFirst(CASLoginProtocol.FORMAT_PARAM)).thenReturn(format);
+        UriInfo uriInfo = mock(UriInfo.class);
+        when(uriInfo.getQueryParameters()).thenReturn(queryParams);
+        return new ContentTypeHelper(uriInfo);
     }
 }

--
Gitblit v1.9.1