@@ -131,6 +131,29 @@ public void combineWithAsteriskWildCard() {
131
131
assertEquals (Arrays .asList (HttpMethod .PUT .name ()), combinedConfig .getAllowedMethods ());
132
132
}
133
133
134
+ @ Test // SPR-14792
135
+ public void combineWithDuplicatedElements () {
136
+ CorsConfiguration config = new CorsConfiguration ();
137
+ config .addAllowedOrigin ("http://domain1.com" );
138
+ config .addAllowedOrigin ("http://domain2.com" );
139
+ config .addAllowedHeader ("header1" );
140
+ config .addAllowedHeader ("header2" );
141
+ config .addExposedHeader ("header3" );
142
+ config .addExposedHeader ("header4" );
143
+ config .addAllowedMethod (HttpMethod .GET .name ());
144
+ config .addAllowedMethod (HttpMethod .PUT .name ());
145
+ CorsConfiguration other = new CorsConfiguration ();
146
+ other .addAllowedOrigin ("http://domain1.com" );
147
+ other .addAllowedHeader ("header1" );
148
+ other .addExposedHeader ("header3" );
149
+ other .addAllowedMethod (HttpMethod .GET .name ());
150
+ CorsConfiguration combinedConfig = config .combine (other );
151
+ assertEquals (Arrays .asList ("http://domain1.com" , "http://domain2.com" ), combinedConfig .getAllowedOrigins ());
152
+ assertEquals (Arrays .asList ("header1" , "header2" ), combinedConfig .getAllowedHeaders ());
153
+ assertEquals (Arrays .asList ("header3" , "header4" ), combinedConfig .getExposedHeaders ());
154
+ assertEquals (Arrays .asList (HttpMethod .GET .name (), HttpMethod .PUT .name ()), combinedConfig .getAllowedMethods ());
155
+ }
156
+
134
157
@ Test
135
158
public void combine () {
136
159
CorsConfiguration config = new CorsConfiguration ();
0 commit comments