forked from apache/shenyu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[type:Integration Test] add integrated-test of Oauth2 plugin (apache#…
…3848) * test oauth * test oauth * test oauth * test delete spring.oauth * test update oauth version * test delete oauth dependency * test all workflow * fix ci * fix ci by update url * fix ci by update example * fix ci by delete example dependency * fix ci by add example-oauth * fix ci * update test case * fix urls * fix ci * fix ci * fix ci * fix ci * fix ci * fix ci by delete oauth yml * update yaml
- Loading branch information
Showing
5 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...amples-http/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.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,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shenyu.examples.http.controller; | ||
|
||
import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* OauthController. | ||
*/ | ||
@RestController | ||
@RequestMapping("/oauth") | ||
@ShenyuSpringMvcClient("/oauth") | ||
public class OauthController { | ||
|
||
/** | ||
* Test oauth2 code request. | ||
* | ||
* @return String | ||
*/ | ||
@GetMapping("/authorize") | ||
public String testCode() { | ||
return "authorize"; | ||
} | ||
|
||
} |
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
51 changes: 51 additions & 0 deletions
51
...ed-test-https/src/test/java/org/apache/shenyu/integrated/test/https/Oauth2PluginTest.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,51 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shenyu.integrated.test.https; | ||
|
||
import org.apache.shenyu.common.enums.PluginEnum; | ||
import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit; | ||
import org.apache.shenyu.integratedtest.common.helper.HttpHelper; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.Future; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class Oauth2PluginTest extends AbstractPluginDataInit { | ||
|
||
@BeforeEach | ||
public void setup() throws IOException { | ||
String pluginResult = initPlugin(PluginEnum.OAUTH2.getName(), ""); | ||
assertThat(pluginResult, is("success")); | ||
} | ||
|
||
@Test | ||
public void testOauthPass() throws ExecutionException, InterruptedException { | ||
Map<String, Object> headers = new HashMap<>(); | ||
Future<String> resp = this.getService().submit(() -> HttpHelper.INSTANCE.getHttpService("http://localhost:8189/oauth/authorize", headers, String.class)); | ||
assertNotNull(resp.get()); | ||
} | ||
|
||
} |