mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🎨 #3231 【小程序】内容安全服务和安全风控服务合并为小程序安全服务WxMaSecurityService
This commit is contained in:
parent
c9b68b5a7c
commit
1589a85064
@ -1,27 +0,0 @@
|
|||||||
package cn.binarywang.wx.miniapp.api;
|
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.bean.safety.request.WxMaUserSafetyRiskRankRequest;
|
|
||||||
import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankResponse;
|
|
||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 小程序安全风控相关接口
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author <a href="https://github.com/azouever">azouever</a>
|
|
||||||
*/
|
|
||||||
public interface WxMaSafetyRiskControlService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 根据提交的用户信息数据获取用户的安全等级,无需用户授权
|
|
||||||
* 文档:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/safety-control-capability/riskControl.getUserRiskRank.html
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @param wxMaUserSafetyRiskRankRequest 获取用户安全等级请求
|
|
||||||
* @throws WxErrorException 通用异常
|
|
||||||
*/
|
|
||||||
WxMaUserSafetyRiskRankResponse getUserRiskRank(WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest) throws WxErrorException;
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,8 @@
|
|||||||
package cn.binarywang.wx.miniapp.api;
|
package cn.binarywang.wx.miniapp.api;
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaMediaAsyncCheckResult;
|
import cn.binarywang.wx.miniapp.bean.WxMaMediaAsyncCheckResult;
|
||||||
|
import cn.binarywang.wx.miniapp.bean.safety.request.WxMaUserSafetyRiskRankRequest;
|
||||||
|
import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankResponse;
|
||||||
import cn.binarywang.wx.miniapp.bean.security.WxMaMediaSecCheckCheckRequest;
|
import cn.binarywang.wx.miniapp.bean.security.WxMaMediaSecCheckCheckRequest;
|
||||||
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckRequest;
|
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckRequest;
|
||||||
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckResponse;
|
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckResponse;
|
||||||
@ -10,13 +12,13 @@ import java.io.File;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 内容安全相关接口.
|
* 小程序安全相关接口.
|
||||||
* Created by Binary Wang on 2018/11/24.
|
* Created by Binary Wang on 2018/11/24.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
*/
|
*/
|
||||||
public interface WxMaSecCheckService {
|
public interface WxMaSecurityService {
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 校验一张图片是否含有违法违规内容.
|
* 校验一张图片是否含有违法违规内容.
|
||||||
@ -109,4 +111,15 @@ public interface WxMaSecCheckService {
|
|||||||
|
|
||||||
WxMaMediaAsyncCheckResult mediaCheckAsync(WxMaMediaSecCheckCheckRequest request) throws WxErrorException;
|
WxMaMediaAsyncCheckResult mediaCheckAsync(WxMaMediaSecCheckCheckRequest request) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 根据提交的用户信息数据获取用户的安全等级,无需用户授权
|
||||||
|
* 文档:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/safety-control-capability/riskControl.getUserRiskRank.html
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param wxMaUserSafetyRiskRankRequest 获取用户安全等级请求
|
||||||
|
* @throws WxErrorException 通用异常
|
||||||
|
*/
|
||||||
|
WxMaUserSafetyRiskRankResponse getUserRiskRank(WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest) throws WxErrorException;
|
||||||
|
|
||||||
}
|
}
|
@ -305,11 +305,11 @@ public interface WxMaService extends WxService {
|
|||||||
WxMaRunService getRunService();
|
WxMaRunService getRunService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回内容安全相关接口服务对象.
|
* 返回小程序安全相关接口服务对象.
|
||||||
*
|
*
|
||||||
* @return WxMaShareService sec check service
|
* @return WxMaShareService sec check service
|
||||||
*/
|
*/
|
||||||
WxMaSecCheckService getSecCheckService();
|
WxMaSecurityService getSecurityService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回插件相关接口服务对象.
|
* 返回插件相关接口服务对象.
|
||||||
@ -486,14 +486,6 @@ public interface WxMaService extends WxService {
|
|||||||
*/
|
*/
|
||||||
WxMaImmediateDeliveryService getWxMaImmediateDeliveryService();
|
WxMaImmediateDeliveryService getWxMaImmediateDeliveryService();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序安全风控相关接口服务
|
|
||||||
*
|
|
||||||
* @return safetyRiskControl service
|
|
||||||
*/
|
|
||||||
WxMaSafetyRiskControlService getSafetyRiskControlService();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分享人接口
|
* 分享人接口
|
||||||
*
|
*
|
||||||
|
@ -57,7 +57,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
|||||||
private final WxMaJsapiService jsapiService = new WxMaJsapiServiceImpl(this);
|
private final WxMaJsapiService jsapiService = new WxMaJsapiServiceImpl(this);
|
||||||
private final WxMaShareService shareService = new WxMaShareServiceImpl(this);
|
private final WxMaShareService shareService = new WxMaShareServiceImpl(this);
|
||||||
private final WxMaRunService runService = new WxMaRunServiceImpl(this);
|
private final WxMaRunService runService = new WxMaRunServiceImpl(this);
|
||||||
private final WxMaSecCheckService secCheckService = new WxMaSecCheckServiceImpl(this);
|
private final WxMaSecurityService securityService = new WxMaSecurityServiceImpl(this);
|
||||||
private final WxMaPluginService pluginService = new WxMaPluginServiceImpl(this);
|
private final WxMaPluginService pluginService = new WxMaPluginServiceImpl(this);
|
||||||
private final WxMaExpressService expressService = new WxMaExpressServiceImpl(this);
|
private final WxMaExpressService expressService = new WxMaExpressServiceImpl(this);
|
||||||
private final WxMaSubscribeService subscribeService = new WxMaSubscribeServiceImpl(this);
|
private final WxMaSubscribeService subscribeService = new WxMaSubscribeServiceImpl(this);
|
||||||
@ -81,7 +81,6 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
|||||||
private final WxMaDeviceSubscribeService deviceSubscribeService = new WxMaDeviceSubscribeServiceImpl(this);
|
private final WxMaDeviceSubscribeService deviceSubscribeService = new WxMaDeviceSubscribeServiceImpl(this);
|
||||||
private final WxMaMarketingService marketingService = new WxMaMarketingServiceImpl(this);
|
private final WxMaMarketingService marketingService = new WxMaMarketingServiceImpl(this);
|
||||||
private final WxMaImmediateDeliveryService immediateDeliveryService = new WxMaImmediateDeliveryServiceImpl(this);
|
private final WxMaImmediateDeliveryService immediateDeliveryService = new WxMaImmediateDeliveryServiceImpl(this);
|
||||||
private final WxMaSafetyRiskControlService safetyRiskControlService = new WxMaSafetyRiskControlServiceImpl(this);
|
|
||||||
private final WxMaShopSharerService shopSharerService = new WxMaShopSharerServiceImpl(this);
|
private final WxMaShopSharerService shopSharerService = new WxMaShopSharerServiceImpl(this);
|
||||||
private final WxMaProductService productService = new WxMaProductServiceImpl(this);
|
private final WxMaProductService productService = new WxMaProductServiceImpl(this);
|
||||||
private final WxMaProductOrderService productOrderService = new WxMaProductOrderServiceImpl(this);
|
private final WxMaProductOrderService productOrderService = new WxMaProductOrderServiceImpl(this);
|
||||||
@ -522,8 +521,8 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxMaSecCheckService getSecCheckService() {
|
public WxMaSecurityService getSecurityService() {
|
||||||
return this.secCheckService;
|
return this.securityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -641,11 +640,6 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
|||||||
return this.immediateDeliveryService;
|
return this.immediateDeliveryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public WxMaSafetyRiskControlService getSafetyRiskControlService() {
|
|
||||||
return this.safetyRiskControlService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxMaShopSharerService getShopSharerService() {
|
public WxMaShopSharerService getShopSharerService() {
|
||||||
return this.shopSharerService;
|
return this.shopSharerService;
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package cn.binarywang.wx.miniapp.api.impl;
|
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaSafetyRiskControlService;
|
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
||||||
import cn.binarywang.wx.miniapp.bean.safety.request.WxMaUserSafetyRiskRankRequest;
|
|
||||||
import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankResponse;
|
|
||||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import me.chanjar.weixin.common.api.WxConsts;
|
|
||||||
import me.chanjar.weixin.common.enums.WxType;
|
|
||||||
import me.chanjar.weixin.common.error.WxError;
|
|
||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
|
||||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
|
||||||
|
|
||||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.InstantDelivery.SafetyRiskControl.GET_USER_RISK_RANK;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author azouever
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class WxMaSafetyRiskControlServiceImpl implements WxMaSafetyRiskControlService {
|
|
||||||
|
|
||||||
private final WxMaService service;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WxMaUserSafetyRiskRankResponse getUserRiskRank(WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest) throws WxErrorException {
|
|
||||||
String responseContent = this.service.post(GET_USER_RISK_RANK, wxMaUserSafetyRiskRankRequest.toJson());
|
|
||||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
|
||||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
|
||||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
|
||||||
}
|
|
||||||
return WxMaUserSafetyRiskRankResponse.fromJson(responseContent);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +1,17 @@
|
|||||||
package cn.binarywang.wx.miniapp.api.impl;
|
package cn.binarywang.wx.miniapp.api.impl;
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaSecCheckService;
|
import cn.binarywang.wx.miniapp.api.WxMaSecurityService;
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaMediaAsyncCheckResult;
|
import cn.binarywang.wx.miniapp.bean.WxMaMediaAsyncCheckResult;
|
||||||
|
import cn.binarywang.wx.miniapp.bean.safety.request.WxMaUserSafetyRiskRankRequest;
|
||||||
|
import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankResponse;
|
||||||
import cn.binarywang.wx.miniapp.bean.security.WxMaMediaSecCheckCheckRequest;
|
import cn.binarywang.wx.miniapp.bean.security.WxMaMediaSecCheckCheckRequest;
|
||||||
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckRequest;
|
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckRequest;
|
||||||
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckResponse;
|
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckResponse;
|
||||||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.chanjar.weixin.common.api.WxConsts;
|
||||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||||
import me.chanjar.weixin.common.enums.WxType;
|
import me.chanjar.weixin.common.enums.WxType;
|
||||||
import me.chanjar.weixin.common.error.WxError;
|
import me.chanjar.weixin.common.error.WxError;
|
||||||
@ -26,14 +29,14 @@ import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
* 小程序安全接口
|
||||||
* Created by Binary Wang on 2018/11/24.
|
* Created by Binary Wang on 2018/11/24.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class WxMaSecCheckServiceImpl implements WxMaSecCheckService {
|
public class WxMaSecurityServiceImpl implements WxMaSecurityService {
|
||||||
private final WxMaService service;
|
private final WxMaService service;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -91,6 +94,16 @@ public class WxMaSecCheckServiceImpl implements WxMaSecCheckService {
|
|||||||
return WxMaGsonBuilder.create().fromJson(response,WxMaMediaAsyncCheckResult.class);
|
return WxMaGsonBuilder.create().fromJson(response,WxMaMediaAsyncCheckResult.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxMaUserSafetyRiskRankResponse getUserRiskRank(WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest) throws WxErrorException {
|
||||||
|
String responseContent = this.service.post(GET_USER_RISK_RANK, wxMaUserSafetyRiskRankRequest.toJson());
|
||||||
|
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||||
|
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||||
|
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||||
|
}
|
||||||
|
return WxMaUserSafetyRiskRankResponse.fromJson(responseContent);
|
||||||
|
}
|
||||||
|
|
||||||
private void parseErrorResponse(String response) throws WxErrorException {
|
private void parseErrorResponse(String response) throws WxErrorException {
|
||||||
JsonObject jsonObject = GsonParser.parse(response);
|
JsonObject jsonObject = GsonParser.parse(response);
|
||||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
@ -351,10 +351,18 @@ public class WxMaApiUrlConstants {
|
|||||||
String GENERATE_SHORT_LINK_URL = "https://api.weixin.qq.com/wxa/genwxashortlink";
|
String GENERATE_SHORT_LINK_URL = "https://api.weixin.qq.com/wxa/genwxashortlink";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序安全
|
||||||
|
*/
|
||||||
public interface SecCheck {
|
public interface SecCheck {
|
||||||
String IMG_SEC_CHECK_URL = "https://api.weixin.qq.com/wxa/img_sec_check";
|
String IMG_SEC_CHECK_URL = "https://api.weixin.qq.com/wxa/img_sec_check";
|
||||||
String MSG_SEC_CHECK_URL = "https://api.weixin.qq.com/wxa/msg_sec_check";
|
String MSG_SEC_CHECK_URL = "https://api.weixin.qq.com/wxa/msg_sec_check";
|
||||||
String MEDIA_CHECK_ASYNC_URL = "https://api.weixin.qq.com/wxa/media_check_async";
|
String MEDIA_CHECK_ASYNC_URL = "https://api.weixin.qq.com/wxa/media_check_async";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户安全等级
|
||||||
|
*/
|
||||||
|
String GET_USER_RISK_RANK = "https://api.weixin.qq.com/wxa/getuserriskrank";
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Setting {
|
public interface Setting {
|
||||||
@ -753,17 +761,6 @@ public class WxMaApiUrlConstants {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 安全风控
|
|
||||||
*/
|
|
||||||
interface SafetyRiskControl {
|
|
||||||
/**
|
|
||||||
* 获取用户的安全等级,无需用户授权
|
|
||||||
*/
|
|
||||||
String GET_USER_RISK_RANK = "https://api.weixin.qq.com/wxa/getuserriskrank";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package cn.binarywang.wx.miniapp.api.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
||||||
import cn.binarywang.wx.miniapp.bean.safety.request.WxMaUserSafetyRiskRankRequest;
|
|
||||||
import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankResponse;
|
|
||||||
import cn.binarywang.wx.miniapp.test.ApiTestModule;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
|
||||||
import org.testng.annotations.Guice;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import static org.testng.AssertJUnit.assertNotNull;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Guice(modules = ApiTestModule.class)
|
|
||||||
public class WxMaSafetyRiskControlServiceImplTest {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected WxMaService wxService;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetUserRiskRank() throws WxErrorException {
|
|
||||||
WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest = WxMaUserSafetyRiskRankRequest.builder()
|
|
||||||
.appid("")
|
|
||||||
.openid("")
|
|
||||||
.scene(1)
|
|
||||||
.isTest(true)
|
|
||||||
.build();
|
|
||||||
WxMaUserSafetyRiskRankResponse wxMaUserSafetyRiskRankResponse = this.wxService.getSafetyRiskControlService().getUserRiskRank(wxMaUserSafetyRiskRankRequest);
|
|
||||||
assertNotNull(wxMaUserSafetyRiskRankResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +1,22 @@
|
|||||||
package cn.binarywang.wx.miniapp.api.impl;
|
package cn.binarywang.wx.miniapp.api.impl;
|
||||||
|
|
||||||
import java.io.File;
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||||
|
import cn.binarywang.wx.miniapp.bean.safety.request.WxMaUserSafetyRiskRankRequest;
|
||||||
|
import cn.binarywang.wx.miniapp.bean.safety.response.WxMaUserSafetyRiskRankResponse;
|
||||||
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckRequest;
|
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckRequest;
|
||||||
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckResponse;
|
import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckResponse;
|
||||||
import org.testng.annotations.*;
|
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
||||||
import cn.binarywang.wx.miniapp.test.ApiTestModule;
|
import cn.binarywang.wx.miniapp.test.ApiTestModule;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
import org.testng.annotations.Guice;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.testng.Assert.*;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
import static org.testng.AssertJUnit.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
@ -24,13 +28,13 @@ import static org.testng.Assert.*;
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Guice(modules = ApiTestModule.class)
|
@Guice(modules = ApiTestModule.class)
|
||||||
public class WxMaSecCheckServiceImplTest {
|
public class WxMaSecurityServiceImplTest {
|
||||||
@Inject
|
@Inject
|
||||||
private WxMaService wxService;
|
private WxMaService wxService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCheckImage() throws WxErrorException {
|
public void testCheckImage() throws WxErrorException {
|
||||||
boolean result = this.wxService.getSecCheckService()
|
boolean result = this.wxService.getSecurityService()
|
||||||
.checkImage(new File(ClassLoader.getSystemResource("tmp.png").getFile()));
|
.checkImage(new File(ClassLoader.getSystemResource("tmp.png").getFile()));
|
||||||
assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
@ -47,7 +51,7 @@ public class WxMaSecCheckServiceImplTest {
|
|||||||
|
|
||||||
@Test(dataProvider = "secData")
|
@Test(dataProvider = "secData")
|
||||||
public void testCheckMessage(String msg, boolean result) throws WxErrorException {
|
public void testCheckMessage(String msg, boolean result) throws WxErrorException {
|
||||||
assertThat(this.wxService.getSecCheckService()
|
assertThat(this.wxService.getSecurityService()
|
||||||
.checkMessage(msg))
|
.checkMessage(msg))
|
||||||
.isEqualTo(result);
|
.isEqualTo(result);
|
||||||
}
|
}
|
||||||
@ -60,7 +64,19 @@ public class WxMaSecCheckServiceImplTest {
|
|||||||
.version("2")
|
.version("2")
|
||||||
.openid("xxx")
|
.openid("xxx")
|
||||||
.build();
|
.build();
|
||||||
WxMaMsgSecCheckCheckResponse response = this.wxService.getSecCheckService().checkMessage(request);
|
WxMaMsgSecCheckCheckResponse response = this.wxService.getSecurityService().checkMessage(request);
|
||||||
assertThat(response).isNotNull();
|
assertThat(response).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetUserRiskRank() throws WxErrorException {
|
||||||
|
WxMaUserSafetyRiskRankRequest wxMaUserSafetyRiskRankRequest = WxMaUserSafetyRiskRankRequest.builder()
|
||||||
|
.appid("")
|
||||||
|
.openid("")
|
||||||
|
.scene(1)
|
||||||
|
.isTest(true)
|
||||||
|
.build();
|
||||||
|
WxMaUserSafetyRiskRankResponse wxMaUserSafetyRiskRankResponse = this.wxService.getSecurityService().getUserRiskRank(wxMaUserSafetyRiskRankRequest);
|
||||||
|
assertNotNull(wxMaUserSafetyRiskRankResponse);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user