mirror of https://github.com/jacekkow/keycloak-protocol-cas

Jacek Kowalski
2023-11-24 8560e4a392962f6b1bdd40f444f091f6a36cdbd4
commit | author | age
5ba0b0 1 package org.keycloak.protocol.cas;
MP 2
fdb9f6 3 import jakarta.ws.rs.core.HttpHeaders;
JK 4 import jakarta.ws.rs.core.MediaType;
5ba0b0 5 import org.jboss.resteasy.mock.MockHttpRequest;
MP 6 import org.jboss.resteasy.mock.MockHttpResponse;
7 import org.jboss.resteasy.specimpl.RequestImpl;
8 import org.junit.Test;
9 import org.keycloak.protocol.cas.utils.ContentTypeHelper;
10
11 import static org.junit.Assert.assertEquals;
12
13 public class ContentTypeHelperTest {
14     @Test
15     public void test() throws Exception {
6fff26 16         assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/").selectResponseType());
JK 17         assertEquals(MediaType.APPLICATION_JSON_TYPE, get("http://example.com/?format=json").selectResponseType());
18         assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/?format=xml").selectResponseType());
19         assertEquals(MediaType.APPLICATION_JSON_TYPE, get("http://example.com/?format=JSON").selectResponseType());
20         assertEquals(MediaType.APPLICATION_XML_TYPE, get("http://example.com/?format=XML").selectResponseType());
5ba0b0 21     }
MP 22
6fff26 23     private ContentTypeHelper get(String uri) throws Exception {
5ba0b0 24         MockHttpRequest req = MockHttpRequest.get(uri);
6fff26 25         return new ContentTypeHelper(req.getUri());
5ba0b0 26     }
MP 27 }