7
7
import org .testng .annotations .Guice ;
8
8
import org .testng .annotations .Test ;
9
9
10
- import javax .crypto .Mac ;
11
- import javax .crypto .spec .SecretKeySpec ;
12
-
13
10
import static org .assertj .core .api .Assertions .assertThat ;
14
11
15
12
/**
@@ -24,27 +21,6 @@ public class WxMaInternetServiceImplTest {
24
21
@ Inject
25
22
private WxMaService wxService ;
26
23
27
- private static String HMACSHA256 (String data , String key ) throws Exception {
28
- Mac sha256_HMAC = Mac .getInstance ("HmacSHA256" );
29
- SecretKeySpec secret_key = new SecretKeySpec (key .getBytes ("UTF-8" ), "HmacSHA256" );
30
- sha256_HMAC .init (secret_key );
31
- byte [] array = sha256_HMAC .doFinal (data .getBytes ("UTF-8" ));
32
- StringBuilder sb = new StringBuilder ();
33
- for (byte item : array ) {
34
- sb .append (Integer .toHexString ((item & 0xFF ) | 0x100 ).substring (1 , 3 ));
35
- }
36
- return sb .toString ().toUpperCase ();
37
- }
38
-
39
- @ Test
40
- public void testGetUserEncryptKey () throws Exception {
41
- String openid = "ogu-84hVFTbTt-myGisQESoDJ6BM" ;
42
- String signature = HMACSHA256 ("" , "9ny8n3t0KULoi0deF7T9pw==" );
43
- String sigMethod = "hmac_sha256" ;
44
- WxMaInternetResponse response = this .wxService .getInternetService ().getUserEncryptKey (openid , signature , sigMethod );
45
- assertThat (response ).isNotNull ();
46
- }
47
-
48
24
@ Test
49
25
public void testGetUserEncryptKey2 () throws Exception {
50
26
String openid = "ogu-84hVFTbTt-myGisQESoDJ6BM" ;
0 commit comments