Skip to content

Commit 548cfb2

Browse files
authored
Active Active Database (#91)
* put active active methods and structs in their own files * add data eviction policy to aa create * redact global_password field
1 parent ef01526 commit 548cfb2

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

client.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ func prettyPrint(data []byte) string {
211211
// redactPasswords: Redacts password values from a JSON message.
212212
func redactPasswords(data string) string {
213213
m1 := regexp.MustCompile(`\"password\"\s*:\s*\"(?:[^"\\]|\\.)*\"`)
214-
return m1.ReplaceAllString(data, "\"password\": \"REDACTED\"")
214+
output := m1.ReplaceAllString(data, "\"password\": \"REDACTED\"")
215+
m2 := regexp.MustCompile(`\"global_password\"\s*:\s*\"(?:[^"\\]|\\.)*\"`)
216+
return m2.ReplaceAllString(output, "\"global_password\": \"REDACTED\"")
215217
}
216218

217219
func escapePath(path string) string {

client_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ func TestCredentialTripper_RedactPasswordFromNestedBody(t *testing.T) {
252252
ProtoMajor: 1,
253253
ProtoMinor: 1,
254254
Header: map[string][]string{},
255-
Body: ioutil.NopCloser(bytes.NewBufferString(`{"security": {"password":"pass"}}`)),
256-
ContentLength: 33,
255+
Body: ioutil.NopCloser(bytes.NewBufferString(`{"security": {"password":"pass", "global_password":"globalpass"}}`)),
256+
ContentLength: 65,
257257
Host: "example.org",
258258
}
259259
expected := &http.Response{
@@ -262,7 +262,7 @@ func TestCredentialTripper_RedactPasswordFromNestedBody(t *testing.T) {
262262
ProtoMajor: 1,
263263
ProtoMinor: 1,
264264
Header: map[string][]string{},
265-
Body: ioutil.NopCloser(bytes.NewBufferString(`{"security": {"password":"REDACTED"}}`)),
265+
Body: ioutil.NopCloser(bytes.NewBufferString(`{"security": {"password":"REDACTED", "global_password":"REDACTED"}}`)),
266266
}
267267

268268
mockTripper.On("RoundTrip", request).Return(expected, nil)
@@ -285,13 +285,14 @@ func TestCredentialTripper_RedactPasswordFromNestedBody(t *testing.T) {
285285
POST /foo/bar HTTP/1.1
286286
Host: example.org
287287
User-Agent: test-user-agent
288-
Content-Length: 33
288+
Content-Length: 65
289289
Accept: application/json
290290
Accept-Encoding: gzip
291291
292292
{
293293
"security": {
294-
"password": "REDACTED"
294+
"password": "REDACTED",
295+
"global_password": "REDACTED"
295296
}
296297
}`, mockLogger.log[0])
297298
}

service/databases/model_active_active.go

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type CreateActiveActiveDatabase struct {
6363
MemoryLimitInGB *float64 `json:"memoryLimitInGb,omitempty"`
6464
SupportOSSClusterAPI *bool `json:"supportOSSClusterApi,omitempty"`
6565
UseExternalEndpointForOSSClusterAPI *bool `json:"useExternalEndpointForOSSClusterApi,omitempty"`
66+
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
6667
GlobalDataPersistence *string `json:"dataPersistence,omitempty"`
6768
GlobalSourceIP []*string `json:"sourceIp,omitempty"`
6869
GlobalPassword *string `json:"password,omitempty"`

0 commit comments

Comments
 (0)