添加测试代码

This commit is contained in:
yadong.zhang 2019-03-22 18:11:19 +08:00
parent 279b6b8b98
commit 5316f3caf9

View File

@ -4,8 +4,6 @@ import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.request.*; import me.zhyd.oauth.request.*;
import org.junit.Test; import org.junit.Test;
import java.io.IOException;
/** /**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com) * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0 * @version 1.0
@ -16,7 +14,7 @@ import java.io.IOException;
public class AuthRequestTest { public class AuthRequestTest {
@Test @Test
public void giteeTest() throws IOException { public void giteeTest() {
AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder() AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.clientId("clientId") .clientId("clientId")
.clientSecret("clientSecret") .clientSecret("clientSecret")
@ -29,7 +27,7 @@ public class AuthRequestTest {
} }
@Test @Test
public void githubTest() throws IOException { public void githubTest() {
AuthRequest authRequest = new AuthGithubRequest(AuthConfig.builder() AuthRequest authRequest = new AuthGithubRequest(AuthConfig.builder()
.clientId("clientId") .clientId("clientId")
.clientSecret("clientSecret") .clientSecret("clientSecret")
@ -42,7 +40,7 @@ public class AuthRequestTest {
} }
@Test @Test
public void weiboTest() throws IOException { public void weiboTest() {
AuthRequest authRequest = new AuthWeiboRequest(AuthConfig.builder() AuthRequest authRequest = new AuthWeiboRequest(AuthConfig.builder()
.clientId("clientId") .clientId("clientId")
.clientSecret("clientSecret") .clientSecret("clientSecret")
@ -57,14 +55,65 @@ public class AuthRequestTest {
@Test @Test
public void dingdingTest() { public void dingdingTest() {
AuthRequest authRequest = new AuthDingTalkRequest(AuthConfig.builder() AuthRequest authRequest = new AuthDingTalkRequest(AuthConfig.builder()
.clientId("dingoa2q6o3fomfk6vdqzy") .clientId("clientId")
.clientSecret("d5w75-R-yNtQsq_Ya_r50gOsKOy9WlmrlUOJkUJXKvsQp7NDPRHsj0epJriiN3yO") .clientSecret("clientSecret")
.redirectUri("http://61.149.7.121:8443/oauth/dingtalk/callback") .redirectUri("redirectUri")
.build()); .build());
// 返回授权页面可自行调整 // 返回授权页面可自行调整
String url = authRequest.authorize(); String url = authRequest.authorize();
System.out.println(url);
// 授权登录后会返回一个code用这个code进行登录 // 授权登录后会返回一个code用这个code进行登录
// authRequest.login("code"); authRequest.login("code");
}
@Test
public void baiduTest() {
AuthRequest authRequest = new AuthBaiduRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.build());
// 返回授权页面可自行调整
String url = authRequest.authorize();
// 授权登录后会返回一个code用这个code进行登录
authRequest.login("code");
}
@Test
public void codingTest() {
AuthRequest authRequest = new AuthCodingRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.build());
// 返回授权页面可自行调整
String url = authRequest.authorize();
// 授权登录后会返回一个code用这个code进行登录
authRequest.login("code");
}
@Test
public void tencentCloudTest() {
AuthRequest authRequest = new AuthTencentCloudRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.build());
// 返回授权页面可自行调整
String url = authRequest.authorize();
// 授权登录后会返回一个code用这个code进行登录
authRequest.login("code");
}
@Test
public void oschinaTest() {
AuthRequest authRequest = new AuthOschinaRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.build());
// 返回授权页面可自行调整
String url = authRequest.authorize();
// 授权登录后会返回一个code用这个code进行登录
authRequest.login("code");
} }
} }