Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat:【企业微信】新增待开发应用获取带参授权链接接口单元测试
  • Loading branch information
jianliang.bai committed Oct 21, 2022
commit 8cd84c5a8ec2edee36968f018e8a8de983378137
7 changes: 7 additions & 0 deletions weixin-java-cp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@
<artifactId>moco-runner</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,27 @@

import com.google.gson.JsonObject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.redis.RedissonWxRedisOps;
import me.chanjar.weixin.cp.bean.WxCpTpAuthInfo;
import me.chanjar.weixin.cp.bean.WxCpTpCorp;
import me.chanjar.weixin.cp.bean.WxCpTpPermanentCodeInfo;
import me.chanjar.weixin.cp.bean.WxTpCustomizedAuthUrl;
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl;
import me.chanjar.weixin.cp.config.impl.WxCpTpRedissonConfigImpl;
import me.chanjar.weixin.cp.tp.service.WxCpTpService;
import org.apache.http.util.Asserts;
import org.mockito.Mockito;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

Expand All @@ -27,6 +38,55 @@
public class BaseWxCpTpServiceImplTest {
private final WxCpTpService tpService = Mockito.spy(new WxCpTpServiceApacheHttpClientImpl());

/**
* The constant PROVIDER_CORP_ID.
*/
public static final String PROVIDER_CORP_ID = "xxxxxx";
/**
* The constant PROVIDER_SECRET.
*/
public static final String PROVIDER_SECRET = "xxxxxx";
/**
* The constant REDIS_ADDR.
*/
public static final String REDIS_ADDR = "redis://xxx.xxx.xxx.xxx:6379";
/**
* The constant REDIS_PASSWD.
*/
public static final String REDIS_PASSWD = "xxxxxx";

private WxCpTpService wxCpTpService;

/**
* Sets up.
*/
@BeforeMethod
public void setUp() {
wxCpTpService = new WxCpTpServiceApacheHttpClientImpl();
wxCpTpService.setWxCpTpConfigStorage(wxCpTpConfigStorage());
}

/**
* Wx cp tp config storage wx cp tp config storage.
*
* @return the wx cp tp config storage
*/
public WxCpTpConfigStorage wxCpTpConfigStorage() {
return WxCpTpRedissonConfigImpl.builder().corpId(PROVIDER_CORP_ID).providerSecret(PROVIDER_SECRET).wxRedisOps(new RedissonWxRedisOps(redissonClient())).build();
}

/**
* Redisson client redisson client.
*
* @return the redisson client
*/
public RedissonClient redissonClient() {
Config config = new Config();
config.useSingleServer().setAddress(REDIS_ADDR).setConnectTimeout(10 * 1000).setDatabase(6)
.setPassword(REDIS_PASSWD).setConnectionMinimumIdleSize(2).setConnectionPoolSize(2);
return Redisson.create(config);
}

/**
* Test check signature.
*/
Expand Down Expand Up @@ -444,4 +504,14 @@ public void testSetTmpDirFile() {
@Test
public void testGetRequestHttp() {
}

@Test
public void testGetCustomizedAuthUrl() throws WxErrorException {
String state = "test";
List<String> templateIdList = Arrays.asList("");

final WxTpCustomizedAuthUrl customizedAuthUrl = wxCpTpService.getCustomizedAuthUrl(state, templateIdList);
Assert.assertNotNull(customizedAuthUrl);
Assert.assertEquals((long) customizedAuthUrl.getErrcode(), 0);
}
}