|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2021 the original author or authors. |
| 2 | + * Copyright 2002-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.security.saml2.provider.service.web.authentication.logout;
|
18 | 18 |
|
| 19 | +import java.io.ByteArrayInputStream; |
| 20 | +import java.io.ByteArrayOutputStream; |
| 21 | +import java.io.IOException; |
| 22 | +import java.io.ObjectInputStream; |
| 23 | +import java.io.ObjectOutputStream; |
19 | 24 | import java.util.HashMap;
|
20 | 25 | import java.util.Map;
|
21 | 26 |
|
@@ -77,6 +82,23 @@ public void loadLogoutRequestWhenMultipleSavedThenReplacesLogoutRequest() {
|
77 | 82 | assertThat(this.logoutRequestRepository.loadLogoutRequest(request)).isEqualTo(two);
|
78 | 83 | }
|
79 | 84 |
|
| 85 | + @Test |
| 86 | + void serializeAndDeserializeSaml2LogoutRequest() throws IOException, ClassNotFoundException { |
| 87 | + Saml2LogoutRequest requestToSerialize = createLogoutRequest().relayState("state-serialized").build(); |
| 88 | + byte[] data; |
| 89 | + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| 90 | + ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream)) { |
| 91 | + objectOutputStream.writeObject(requestToSerialize); |
| 92 | + data = outputStream.toByteArray(); |
| 93 | + } |
| 94 | + |
| 95 | + try (ByteArrayInputStream inputStream = new ByteArrayInputStream(data); |
| 96 | + ObjectInputStream objectInputStream = new ObjectInputStream(inputStream)) { |
| 97 | + Saml2LogoutRequest deserializedRequest = (Saml2LogoutRequest) objectInputStream.readObject(); |
| 98 | + assertThat(requestToSerialize.getRelayState()).isEqualTo(deserializedRequest.getRelayState()); |
| 99 | + } |
| 100 | + } |
| 101 | + |
80 | 102 | @Test
|
81 | 103 | public void loadLogoutRequestWhenSavedAndStateParameterNullThenReturnNull() {
|
82 | 104 | MockHttpServletRequest request = new MockHttpServletRequest();
|
|
0 commit comments