forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 1
/
alter_user_scram_credentials_request_test.go
60 lines (55 loc) · 1.77 KB
/
alter_user_scram_credentials_request_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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package sarama
import "testing"
var (
emptyAlterUserScramCredentialsRequest = []byte{
1, // Deletions
1, // Upsertions
0, // empty tagged fields
}
userAlterUserScramCredentialsRequest = []byte{
2, // Deletions array, length 1
7, // User name length 6
'd', 'e', 'l', 'e', 't', 'e', // User name
2, // SCRAM_SHA_512
0, // empty tagged fields
2, // Upsertions array, length 1
7, // User name length 6
'u', 'p', 's', 'e', 'r', 't',
1, // SCRAM_SHA_256
0, 0, 16, 0, // iterations: 4096
// salt bytes:
6, 119, 111, 114, 108, 100,
// saltedPassword:
33, 193, 85, 83, 3, 218, 48, 159, 107, 125, 30, 143,
228, 86, 54, 191, 221, 220, 75, 245, 100, 5, 231,
233, 78, 157, 21, 240, 231, 185, 203, 211, 128,
0, // empty tagged fields
0, // empty tagged fields
}
)
func TestAlterUserScramCredentialsRequest(t *testing.T) {
request := &AlterUserScramCredentialsRequest{
Version: 0,
Deletions: []AlterUserScramCredentialsDelete{},
Upsertions: []AlterUserScramCredentialsUpsert{},
}
// Password is not transmitted, will fail with `testRequest` and `DeepEqual` check
testRequestEncode(t, "no upsertions/deletions", request, emptyAlterUserScramCredentialsRequest)
request.Deletions = []AlterUserScramCredentialsDelete{
{
Name: "delete",
Mechanism: SCRAM_MECHANISM_SHA_512,
},
}
request.Upsertions = []AlterUserScramCredentialsUpsert{
{
Name: "upsert",
Mechanism: SCRAM_MECHANISM_SHA_256,
Iterations: 4096,
Salt: []byte("world"),
Password: []byte("hello"),
},
}
// Password is not transmitted, will fail with `testRequest` and `DeepEqual` check
testRequestEncode(t, "single deletion and upsertion", request, userAlterUserScramCredentialsRequest)
}