TokenTest.java
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.erry.iclear.dateInterface;
import com.arronlong.httpclientutil.HttpClientUtil;
import com.arronlong.httpclientutil.common.HttpConfig;
import com.erry.iclear.dateInterface.api.response.TokenResult;
import com.erry.iclear.dateInterface.util.HttpUtils;
import com.erry.iclear.dateInterface.util.JsonToJava;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
public class TokenTest extends IClearApiApplicationTests {
@Value("${api.token-info.username}")
String username;
@Value("${api.token-info.password}")
String password;
@Value("${api.address.token-url}")
String tokenUrl;
@Value("${api.address.refresh-token-url}")
String refreshTokenUrl;
@Value("${api.address.customs-url}")
String customsUrl;
@Value("${api.address.complete-msg-url}")
String completeMsgUrl;
@Test
public void token() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
map.put("username", this.username);
map.put("password", this.password);
HttpConfig config = HttpConfig.custom()
.url(tokenUrl)
.map(map)
.encoding("utf-8");
String token = HttpClientUtil.post(config);
TokenResult rss = JsonToJava.parseJson(token, TokenResult.class);
System.out.println(token);
System.out.println(refreshTokenUrl);
token = "eyJhbGciOiJSUzI1NiJ9.eyJleHBpcmVBdCI6MTYyNzQ3MTkyNjIxMCwidXNlcklkIjoiaWNsZWFyX2V4dGVybmFsX2N0bSJ9.dGrNuB8yHkeDM2Cmxwa7tej30fxQ6BpKYieWYh2kaW_nx75Hit8wy3FiLZTEgfXqa4o2axJEslrPgzedle5j5PIlTl-vz1WcCKDvLAh0PNeCX6i7NmpMKwemPAJp8gdo1HYjMdJPn7cV7Cjc7rSS1zjS4NCu0Ob7Qjf_FKopBYYJUITGy79Y0XbDo9_tHxS-2_8ahU3q78l799amQughnnMU3srpD9PLyKNO8uz6l-eV6ShSfYNE0o2L1FSH8xgqpIKNrRsl-JKasHIQl-82CiX-2XEtFFU4JbxDp9t-7jo-UlEIIKWk1Gy10nVC9FSntFFIHgTJ2lMAxF7QqI3QlQ";
Map<String,Object> map1 = new HashMap<String,Object>();
map1.put("token", rss.getData().getToken());
HttpConfig config1 = HttpConfig.custom()
.url(refreshTokenUrl)
.map(map1)
.encoding("utf-8");
String rs = HttpClientUtil.post(config1);
System.out.println(rs);
}
/* public static void main(String[] args) throws Exception{
String url = "https://apictm.iclrccd-fedex.com/login";
Map<String,String> map = new HashMap<String,String>();
map.put("username", "iclear_export_prod");
map.put("password", "1qaz@WSX");
// String token = httpUtils.doPost(url,map);
// TokenResult rss = JsonToJava.parseJson(token, TokenResult.class);
// System.out.println(rss.getData().getToken());
map.clear();
url = "https://apictm.iclrccd-fedex.com/admin/user/token/refresh";
map.put("token","eyJhbGciOiJSUzI1NiJ9.eyJleHBpcmVBdCI6MTY0Njg4MDc3NzY0NSwidXNlcklkIjoiaWNsZWFyX2V4cG9ydF9wcm9kIn0.fey8YVWL0wcxvCUMQR-ePyCXIh9AdoztIixtcYgGjtaUCxO3VVf9Jmut3ZVVelxigvTDzv-Iz097R2fgBSOBzStICTZGqxmRV7Av6R41HCTTQ8BL6aSPle2QszSkTt5T95cYiFYSv9CHmxSKBU_MrJk5WhCJb5XOAmWmdV94McFWTBi1oTIjVfgiczu0pzgA1berR1lfUIEDVEUxUoduVARzwUcDDljq0pf-rPhpAj-Iqbhc4fint4Th-BlO6Rg4ZWYB08-3Id9krl92TMJJ_rXMrhbna6833r8PcpdbXIFPkuopbrv9GL1Ds_vWL7Sd5BTSYtMRn2ku0GhAP6GNPg");
String rs = httpUtils.doPost(url,map);
System.out.println(rs);
}*/
private static HttpUtils httpUtils = new HttpUtils();
}