// Copyright (c) 2023 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package scrubber56import (7"encoding/json"8"testing"9)1011func TestScrub(t *testing.T) {1213scrubber := Default1415// log.WithFieldSensitive("workspaceID", "gitpodio-gitpod-uesaddev73c").Info("hello world")16scrubber.KeyValue("workspaceID", "gitpodio-gitpod-uesaddev73c") // -> [scrubbed:md5:ae3e415b124cdbac878e995cad169490]1718var someJSONData = json.RawMessage(`{"email": "[email protected]", "username": "foobar", "orgID": "112233", "desc": "the email is [email protected]"}`)19scrubber.JSON(someJSONData) // -> `{"email": "[scrubbed:md5:e2e6d7a977f2ca2b3900e22c68655b30]", "username": "[scrubbed:md5:14758f1afd44c09b7992073ccf00b43d]", "orgID": "[scrubbed:md5:cc9d7e078ba46da002aba1cf665b0acf]", "desc": "the email is [scrubbed:email]"}`2021var user = User{22Username: "foobar",23Email: "[email protected]",24AuthToken: "112233",25}26scrubber.Struct(&user) // -> {Username: "[scrubbed:md5:14758f1afd44c09b7992073ccf00b43d]", Email: "[scrubbed:md5:e2e6d7a977f2ca2b3900e22c68655b30]", AuthToken: "[scrubbed]"}2728scrubber.Value("this may be an email: [email protected]") // -> "this may be an email: [scrubbed:md5:e2e6d7a977f2ca2b3900e22c68655b30:email]"29}3031type User struct {32Username string33Email string34AuthToken string `scrub:"redact"`35}363738