@@ -60,12 +60,27 @@ void constructor_successOidcResponse() throws IOException {
6060
6161 assertTrue (response .isSuccessful ());
6262 assertTrue (response .isValid ());
63- assertEquals (1 , response .getVersion ());
63+ assertEquals (EXECUTABLE_SUPPORTED_MAX_VERSION , response .getVersion ());
6464 assertEquals (TOKEN_TYPE_OIDC , response .getTokenType ());
6565 assertEquals (ID_TOKEN , response .getSubjectToken ());
6666 assertEquals (
6767 Instant .now ().getEpochSecond () + EXPIRATION_DURATION , response .getExpirationTime ());
68- assertEquals (1 , response .getVersion ());
68+ }
69+
70+ @ Test
71+ void constructor_successOidcResponseMissingExpirationTimeField_notExpired () throws IOException {
72+ GenericJson jsonResponse = buildOidcResponse ();
73+ jsonResponse .remove ("expiration_time" );
74+
75+ ExecutableResponse response = new ExecutableResponse (jsonResponse );
76+
77+ assertTrue (response .isSuccessful ());
78+ assertTrue (response .isValid ());
79+ assertFalse (response .isExpired ());
80+ assertEquals (EXECUTABLE_SUPPORTED_MAX_VERSION , response .getVersion ());
81+ assertEquals (TOKEN_TYPE_OIDC , response .getTokenType ());
82+ assertEquals (ID_TOKEN , response .getSubjectToken ());
83+ assertNull (response .getExpirationTime ());
6984 }
7085
7186 @ Test
@@ -81,17 +96,33 @@ void constructor_successSamlResponse() throws IOException {
8196 Instant .now ().getEpochSecond () + EXPIRATION_DURATION , response .getExpirationTime ());
8297 }
8398
99+ @ Test
100+ void constructor_successSamlResponseMissingExpirationTimeField_notExpired () throws IOException {
101+ GenericJson jsonResponse = buildSamlResponse ();
102+ jsonResponse .remove ("expiration_time" );
103+
104+ ExecutableResponse response = new ExecutableResponse (jsonResponse );
105+
106+ assertTrue (response .isSuccessful ());
107+ assertTrue (response .isValid ());
108+ assertFalse (response .isExpired ());
109+ assertEquals (EXECUTABLE_SUPPORTED_MAX_VERSION , response .getVersion ());
110+ assertEquals (TOKEN_TYPE_SAML , response .getTokenType ());
111+ assertEquals (SAML_RESPONSE , response .getSubjectToken ());
112+ assertNull (response .getExpirationTime ());
113+ }
114+
84115 @ Test
85116 void constructor_validErrorResponse () throws IOException {
86117 ExecutableResponse response = new ExecutableResponse (buildErrorResponse ());
87118
88119 assertFalse (response .isSuccessful ());
89120 assertFalse (response .isValid ());
90- assertTrue (response .isExpired ());
121+ assertFalse (response .isExpired ());
91122 assertNull (response .getSubjectToken ());
92123 assertNull (response .getTokenType ());
93124 assertNull (response .getExpirationTime ());
94- assertEquals (1 , response .getVersion ());
125+ assertEquals (EXECUTABLE_SUPPORTED_MAX_VERSION , response .getVersion ());
95126 assertEquals ("401" , response .getErrorCode ());
96127 assertEquals ("Caller not authorized." , response .getErrorMessage ());
97128 }
@@ -189,23 +220,6 @@ void constructor_successResponseMissingTokenTypeField_throws() {
189220 exception .getMessage ());
190221 }
191222
192- @ Test
193- void constructor_successResponseMissingExpirationTimeField_throws () {
194- GenericJson jsonResponse = buildOidcResponse ();
195- jsonResponse .remove ("expiration_time" );
196-
197- PluggableAuthException exception =
198- assertThrows (
199- PluggableAuthException .class ,
200- () -> new ExecutableResponse (jsonResponse ),
201- "Exception should be thrown." );
202-
203- assertEquals (
204- "Error code INVALID_EXECUTABLE_RESPONSE: The executable response is missing the "
205- + "`expiration_time` field." ,
206- exception .getMessage ());
207- }
208-
209223 @ Test
210224 void constructor_samlResponseMissingSubjectToken_throws () {
211225 GenericJson jsonResponse = buildSamlResponse ();
0 commit comments