-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle CORS in cloud gateway (#2701)
* configure cors per route PoC Signed-off-by: achmelo <[email protected]> * move cors to common module, refactor cgw part Signed-off-by: achmelo <[email protected]> * fix bugs Signed-off-by: achmelo <[email protected]> * fix bugs Signed-off-by: achmelo <[email protected]> * utils test Signed-off-by: achmelo <[email protected]> * acceptance tests Signed-off-by: achmelo <[email protected]> * cover remaining parts Signed-off-by: achmelo <[email protected]> * code review Signed-off-by: achmelo <[email protected]> Signed-off-by: achmelo <[email protected]>
- Loading branch information
Showing
19 changed files
with
420 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...rvice/src/test/java/org/zowe/apiml/cloudgatewayservice/acceptance/CorsPerServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.cloudgatewayservice.acceptance; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
import org.zowe.apiml.cloudgatewayservice.acceptance.common.AcceptanceTest; | ||
import org.zowe.apiml.cloudgatewayservice.acceptance.common.AcceptanceTestWithTwoServices; | ||
|
||
import java.io.IOException; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.apache.http.HttpStatus.SC_OK; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
@AcceptanceTest | ||
class CorsPerServiceTest extends AcceptanceTestWithTwoServices { | ||
|
||
@Test | ||
void routeToServiceWithCorsEnabled() throws IOException { | ||
mockServerWithSpecificHttpResponse(200, "serviceid2", 4000, (headers) -> | ||
assertTrue(headers != null && headers.get("Origin") == null) | ||
); | ||
given() | ||
.header("Origin", "https://localhost:3000") | ||
.header("X-Request-Id", "serviceid2localhost") | ||
.when() | ||
.get(basePath + serviceWithDefaultConfiguration.getPath()) | ||
.then().statusCode(Matchers.is(SC_OK)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.