forked from vitessio/vitess
/
replication_test.go
46 lines (38 loc) · 1 KB
/
replication_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
// Copyright 2014, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mysqlctl
import (
"testing"
)
func testRedacted(t *testing.T, source, expected string) {
if r := redactMasterPassword(source); r != expected {
t.Errorf("redactMasterPassword bad result: %v\nWas expecting:%v", r, expected)
}
}
func TestRedactMasterPassword(t *testing.T) {
// regular test case
testRedacted(t, `CHANGE MASTER TO
MASTER_PASSWORD = 'AAA',
MASTER_CONNECT_RETRY = 1
`,
`CHANGE MASTER TO
MASTER_PASSWORD = '***',
MASTER_CONNECT_RETRY = 1
`)
// empty password
testRedacted(t, `CHANGE MASTER TO
MASTER_PASSWORD = '',
MASTER_CONNECT_RETRY = 1
`,
`CHANGE MASTER TO
MASTER_PASSWORD = '',
MASTER_CONNECT_RETRY = 1
`)
// no beginning match
testRedacted(t, "aaaaaaaaaaaaaa", "aaaaaaaaaaaaaa")
// no end match
testRedacted(t, `CHANGE MASTER TO
MASTER_PASSWORD = 'AAA`, `CHANGE MASTER TO
MASTER_PASSWORD = 'AAA`)
}