File tree 2 files changed +33
-0
lines changed
commercetools/commercetools-sdk-java-api/src
integrationTest/java/commercetools/cart
test/java/com/commercetools
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 15
15
import commercetools .discount_code .DiscountCodeFixtures ;
16
16
import commercetools .utils .CommercetoolsTestUtils ;
17
17
18
+ import io .vrap .rmf .base .client .error .NotFoundException ;
19
+
18
20
import org .assertj .core .api .Assertions ;
19
21
import org .junit .jupiter .api .Test ;
20
22
@@ -151,6 +153,16 @@ public void expandDiscountCodeReference() {
151
153
});
152
154
}
153
155
156
+ @ Test
157
+ public void pathTraversal () {
158
+ CartsFixtures .withCart (cart -> {
159
+ NotFoundException e = org .junit .jupiter .api .Assertions .assertThrows (NotFoundException .class , () -> {
160
+ CommercetoolsTestUtils .getProjectApiRoot ().carts ().withId ("../categories" ).get ().executeBlocking ();
161
+ });
162
+ Assertions .assertThat (e .getMessage ()).contains ("..%2Fcategories" );
163
+ });
164
+ }
165
+
154
166
private void withUpdateableCartAndDiscount (final BiFunction <Cart , DiscountCode , Cart > function ) {
155
167
DiscountCodeFixtures
156
168
.withUpdateableDiscountCode (discountCodeDraftBuilder -> discountCodeDraftBuilder .isActive (true )
Original file line number Diff line number Diff line change
1
+
2
+ package com .commercetools ;
3
+
4
+ import com .commercetools .api .client .ProjectApiRoot ;
5
+ import com .commercetools .api .defaultconfig .ApiRootBuilder ;
6
+
7
+ import io .vrap .rmf .base .client .ApiHttpRequest ;
8
+
9
+ import org .assertj .core .api .Assertions ;
10
+ import org .junit .jupiter .api .Test ;
11
+
12
+ public class EncodePathParamTest {
13
+ @ Test
14
+ public void testPathTraversal () {
15
+ final ProjectApiRoot project = ApiRootBuilder .of ().withApiBaseUrl ("" ).build ("test" );
16
+
17
+ final ApiHttpRequest httpRequest = project .carts ().withId ("../categories" ).get ().createHttpRequest ();
18
+ Assertions .assertThat (httpRequest .getUri ().toString ()).isEqualTo ("test/carts/..%2Fcategories" );
19
+ }
20
+
21
+ }
You can’t perform that action at this time.
0 commit comments