Skip to content

Commit 76ecb40

Browse files
milanmajchrakclaude
andcommitted
ZCU-DATA/test: fail cleanly on a missing Authorization header, avoid a raw-type read
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 686c7ab commit 76ecb40

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

dspace-server-webapp/src/test/java/org/dspace/app/rest/security/ClarinShibbolethSpecialGroupsIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
*/
88
package org.dspace.app.rest.security;
99

10+
import static org.junit.Assert.assertNotNull;
1011
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
1112
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
1213
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
1314

1415
import java.io.InputStream;
15-
import java.util.Map;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
1818
import org.apache.commons.codec.CharEncoding;
@@ -163,6 +163,7 @@ private String shibLogin() throws Exception {
163163
.header("SHIB-NETID", NET_ID_TEST_EPERSON))
164164
.andExpect(status().is3xxRedirection())
165165
.andReturn().getResponse().getHeader("Authorization");
166+
assertNotNull("The shibboleth login must return the Authorization header", authHeader);
166167
return authHeader.replace(AUTHORIZATION_TYPE, "");
167168
}
168169

@@ -172,7 +173,6 @@ private String getShortLivedToken(String loginToken) throws Exception {
172173
.andExpect(status().isOk())
173174
.andReturn();
174175
String content = mvcResult.getResponse().getContentAsString();
175-
Map<String, Object> map = mapper.readValue(content, Map.class);
176-
return String.valueOf(map.get("token"));
176+
return mapper.readTree(content).get("token").asText();
177177
}
178178
}

0 commit comments

Comments
 (0)