-
Notifications
You must be signed in to change notification settings - Fork 1
/
auth_test.go
27 lines (23 loc) · 1.1 KB
/
auth_test.go
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
package bili
import (
"github.com/stretchr/testify/assert"
"strings"
"testing"
)
func TestClient_GetCaptcha(t *testing.T) {
response, err := client.GetCaptcha()
assert.Nil(t, err, "cannot get captcha")
assert.Equal(t, response.Code, CaptchaSuccess, "response code is not 0")
assert.Equal(t, response.Data.Result.Success, 1, "Success is not 1")
}
func TestClient_GetPasswordSaltAndRSA(t *testing.T) {
response, err := client.GetPasswordSaltAndRSA()
assert.Nil(t, err, "cannot get password salt and rsa")
assert.NotEmpty(t, response.Hash)
assert.True(t, strings.HasPrefix(response.Key, "-----BEGIN PUBLIC KEY-----\n"))
}
func TestClient_EncryptPasswordWithSaltAndRSA(t *testing.T) {
_, err := client.EncryptPasswordWithSaltAndRSA(
"BiShi22332323", "8e0db05c46f4052c", "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDjb4V7EidX/ym28t2ybo0U6t0n\n6p4ej8VjqKHg100va6jkNbNTrLQqMCQCAYtXMXXp2Fwkk6WR+12N9zknLjf+C9sx\n/+l48mjUU8RqahiFD1XT/u2e0m2EN029OhCgkHx3Fc/KlFSIbak93EH/XlYis0w+\nXl69GV6klzgxW6d2xQIDAQAB\n-----END PUBLIC KEY-----")
assert.Nil(t, err, "cannot encrypt password with salt and rsa")
}