MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestSensitiveData

Function TestSensitiveData

backend/tests/sensitive_data_test.go:84–320  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82)
83
84func TestSensitiveData(t *testing.T) {
85 const (
86 databaseName = "sensitive_data"
87 tableName = "tech_book"
88 createTable = `
89 CREATE TABLE tech_book(
90 id int primary key,
91 name varchar(220),
92 author varchar(220)
93 );
94 `
95 insertData = `
96 INSERT INTO tech_book VALUES
97 (1, 'bytebase', 'bber'),
98 (2, 'PostgreSQL 14 Internals', 'Egor Rogov'),
99 (3, 'Designing Data-Intensive Applications', 'Martin Kleppmann');
100 `
101 queryTable = `SELECT * FROM tech_book`
102 )
103 t.Parallel()
104 a := require.New(t)
105 ctx := context.Background()
106 ctl := &controller{}
107 ctx, err := ctl.StartServerWithExternalPg(ctx)
108 a.NoError(err)
109 defer ctl.Close(ctx)
110
111 _, err = ctl.settingServiceClient.UpdateSetting(ctx, connect.NewRequest(&v1pb.UpdateSettingRequest{
112 Setting: &v1pb.Setting{
113 Name: "settings/" + v1pb.Setting_SEMANTIC_TYPES.String(),
114 Value: &v1pb.SettingValue{
115 Value: &v1pb.SettingValue_SemanticType{
116 SemanticType: &v1pb.SemanticTypeSetting{
117 Types: []*v1pb.SemanticTypeSetting_SemanticType{
118 {
119 Id: "default",
120 Title: "Default",
121 Algorithm: &v1pb.Algorithm{
122 Mask: &v1pb.Algorithm_FullMask_{FullMask: &v1pb.Algorithm_FullMask{Substitution: "******"}},
123 },
124 },
125 },
126 },
127 },
128 },
129 },
130 AllowMissing: true,
131 }))
132 a.NoError(err)
133
134 mysqlContainer, err := getMySQLContainer(ctx)
135 defer func() {
136 mysqlContainer.Close(ctx)
137 }()
138 a.NoError(err)
139
140 mysqlDB := mysqlContainer.db
141 _, err = mysqlDB.Exec(fmt.Sprintf("DROP DATABASE IF EXISTS %v", databaseName))

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
createDatabaseMethod · 0.95
changeDatabaseMethod · 0.95
adminQueryMethod · 0.95
getMySQLContainerFunction · 0.85
generateRandomStringFunction · 0.85
GetSyntaxErrorMethod · 0.80
LenMethod · 0.80
UpdateSettingMethod · 0.65
StringMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected