| 1234567891011121314151617181920212223242526272829303132333435363738 |
- package com.adx.tencent.oppo.client;
- import org.junit.jupiter.api.Test;
- import java.util.Map;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import static org.junit.jupiter.api.Assertions.assertTrue;
- class OppoClientTest {
- private static final String KEY = "XGAXicVG5GMBsx5bueOe4w==";
- @Test
- void calculatesDocumentedSignature() throws Exception {
- String body = "{\"payAmount\":100,\"adId\":101097648,\"appType\":1,\"clientIp\":\"127.0.0.1\",\"dataType\":1,\"ascribeType\":1,\"channel\":1,\"imei\":\"XJMyaLt8fDlv4a9b8/0RNQ==\",\"type\":1,\"pkg\":\"com.oppo.test\",\"mac\":\"TEViR6jSgD/lECBl3Ah70eNy2gUQrQlekHkWqEGkZsU=\",\"timestamp\":1571995483916}";
- assertEquals("ce14fcc22abd7461e860263a8da983eb",
- OppoClient.md5(body + "1571995483916" + "e0u6fnlag06lc3pl"));
- }
- @Test
- void encryptsDeviceValuesWithDocumentedAes() throws Exception {
- OppoClient client = new OppoClient(null, "", KEY, (String) null, new com.fasterxml.jackson.databind.ObjectMapper());
- assertEquals("XJMyaLt8fDlv4a9b8/0RNQ==", client.encrypt("868123039927020"));
- }
- @Test
- void exposesStableRequestFields() {
- assertEquals("https://api.ads.heytapmobi.com/api/uploadActiveData", OppoClient.DEFAULT_ENDPOINT);
- Map<String, Object> body = Map.of("dataType", 1);
- assertEquals(1, body.get("dataType"));
- }
- @Test
- void tokenPayloadUsesDocumentedShape() {
- String payload = "owner,api,123,signature";
- assertTrue(java.util.Base64.getEncoder().encodeToString(payload.getBytes()).length() > payload.length());
- }
- }
|