forked from segmentio/kafka-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alteruserscramcredentials_test.go
73 lines (58 loc) · 1.71 KB
/
alteruserscramcredentials_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
61
62
63
64
65
66
67
68
69
70
71
72
73
package kafka
import (
"context"
"testing"
ktesting "github.com/segmentio/kafka-go/testing"
)
func TestAlterUserScramCredentials(t *testing.T) {
// https://issues.apache.org/jira/browse/KAFKA-10259
if !ktesting.KafkaIsAtLeast("2.7.0") {
return
}
client, shutdown := newLocalClient()
defer shutdown()
name := makeTopic()
createRes, err := client.AlterUserScramCredentials(context.Background(), &AlterUserScramCredentialsRequest{
Upsertions: []UserScramCredentialsUpsertion{
{
Name: name,
Mechanism: ScramMechanismSha512,
Iterations: 15000,
Salt: []byte("my-salt"),
SaltedPassword: []byte("my-salted-password"),
},
},
})
if err != nil {
t.Fatal(err)
}
if len(createRes.Results) != 1 {
t.Fatalf("expected 1 createResult; got %d", len(createRes.Results))
}
if createRes.Results[0].User != name {
t.Fatalf("expected createResult with user: %s, got %s", name, createRes.Results[0].User)
}
if createRes.Results[0].Error != nil {
t.Fatalf("didn't expect an error in createResult, got %v", createRes.Results[0].Error)
}
deleteRes, err := client.AlterUserScramCredentials(context.Background(), &AlterUserScramCredentialsRequest{
Deletions: []UserScramCredentialsDeletion{
{
Name: name,
Mechanism: ScramMechanismSha512,
},
},
})
if err != nil {
t.Fatal(err)
}
if len(deleteRes.Results) != 1 {
t.Fatalf("expected 1 deleteResult; got %d", len(deleteRes.Results))
}
if deleteRes.Results[0].User != name {
t.Fatalf("expected deleteResult with user: %s, got %s", name, deleteRes.Results[0].User)
}
if deleteRes.Results[0].Error != nil {
t.Fatalf("didn't expect an error in deleteResult, got %v", deleteRes.Results[0].Error)
}
}