1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 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.
@@ -68,8 +68,8 @@ void parseHeaderWithoutAttributes() {
68
68
assertCookie (cookie , "SESSION" , "123" );
69
69
}
70
70
71
- @ SuppressWarnings ("removal" )
72
71
@ Test
72
+ @ SuppressWarnings ("removal" )
73
73
void parseHeaderWithAttributes () {
74
74
MockCookie cookie = MockCookie .parse ("SESSION=123; Domain=example.com; Max-Age=60; " +
75
75
"Expires=Tue, 8 Oct 2019 19:50:00 GMT; Path=/; Secure; HttpOnly; Partitioned; SameSite=Lax" );
@@ -87,6 +87,19 @@ void parseHeaderWithAttributes() {
87
87
assertThat (cookie .getComment ()).isNull ();
88
88
}
89
89
90
+ @ Test // gh-34575
91
+ void parseHeaderWithOptionalAttributes () {
92
+ MockCookie cookie = MockCookie .parse ("SESSION=123; HttpOnly; Version=1; Partitioned; Secure" );
93
+
94
+ assertCookie (cookie , "SESSION" , "123" );
95
+ assertThat (cookie .isHttpOnly ()).isTrue ();
96
+ assertThat (cookie .getSecure ()).isTrue ();
97
+ assertThat (cookie .isPartitioned ()).isTrue ();
98
+ assertThat (cookie .getAttribute ("Partitioned" )).isEmpty ();
99
+ assertThat (cookie .getAttribute ("Version" )).isEqualTo ("1" );
100
+ assertThat (cookie .getAttribute ("BOGUS" )).isNull ();
101
+ }
102
+
90
103
@ ParameterizedTest
91
104
@ ValueSource (strings = {"0" , "bogus" })
92
105
void parseHeaderWithInvalidExpiresAttribute (String expiresValue ) {
@@ -209,10 +222,13 @@ void setInvalidAttributeExpiresShouldThrow() {
209
222
void setPartitioned () {
210
223
MockCookie cookie = new MockCookie ("SESSION" , "123" );
211
224
assertThat (cookie .isPartitioned ()).isFalse ();
225
+ assertThat (cookie .getAttribute ("Partitioned" )).isNull ();
212
226
cookie .setPartitioned (true );
213
227
assertThat (cookie .isPartitioned ()).isTrue ();
228
+ assertThat (cookie .getAttribute ("Partitioned" )).isEmpty ();
214
229
cookie .setPartitioned (false );
215
230
assertThat (cookie .isPartitioned ()).isFalse ();
231
+ assertThat (cookie .getAttribute ("Partitioned" )).isNull ();
216
232
}
217
233
218
234
}
0 commit comments