Skip to content

Commit

Permalink
Merge #67064 #67111
Browse files Browse the repository at this point in the history
67064: deps: bump cockroachdb/redact r=tbg a=knz

Fixes #64158

This introduces smart auto-formatting of structs and arrays
in redaction contexts.

This is a simplified version of  #66880 to avoid the bazel brokenness.

67111: backupccl: Add a test to verify only admins can control schedules. r=miretskiy a=miretskiy

Add a test to verify only admins can control schedules.

Release Notes: None

Co-authored-by: Raphael 'kena' Poss <[email protected]>
Co-authored-by: Yevgeniy Miretskiy <[email protected]>
  • Loading branch information
3 people committed Jul 1, 2021
3 parents c4b372e + 557dc44 + 43e8375 commit c452a0c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ def go_deps():
name = "com_github_cockroachdb_redact",
build_file_proto_mode = "disable_global",
importpath = "github.com/cockroachdb/redact",
sum = "h1:sjlUvGorKMIVQfo+w2RqDi5eewCHn453C/vdIXMzjzI=",
version = "v1.0.9",
sum = "h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ=",
version = "v1.1.3",
)
go_repository(
name = "com_github_cockroachdb_returncheck",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/cockroachdb/gostdlib v1.13.0
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f
github.com/cockroachdb/pebble v0.0.0-20210622171231-4fcf40933159
github.com/cockroachdb/redact v1.0.9
github.com/cockroachdb/redact v1.1.3
github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2
github.com/cockroachdb/stress v0.0.0-20170808184505-29b5d31b4c3a
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ github.com/cockroachdb/pebble v0.0.0-20210622171231-4fcf40933159/go.mod h1:JXfQr
github.com/cockroachdb/pq v0.0.0-20210517091544-990dd3347596 h1:xTc0ViFhuelzQZAYQOxMR2J5QDO9/C+0L0fkPXIcoMI=
github.com/cockroachdb/pq v0.0.0-20210517091544-990dd3347596/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/cockroachdb/redact v1.0.8/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/redact v1.0.9 h1:sjlUvGorKMIVQfo+w2RqDi5eewCHn453C/vdIXMzjzI=
github.com/cockroachdb/redact v1.0.9/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ=
github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd h1:KFOt5I9nEKZgCnOSmy8r4Oykh8BYQO8bFOTgHDS8YZA=
github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd/go.mod h1:AN708GD2FFeLgUHMbD58YPe4Nw8GG//3rwgyG4L9gR0=
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM=
Expand Down
20 changes: 20 additions & 0 deletions pkg/jobs/schedule_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ package jobs

import (
"context"
gosql "database/sql"
"fmt"
"net/url"
"strings"
"testing"
"time"
Expand All @@ -23,6 +25,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/security"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -117,6 +120,23 @@ func TestScheduleControl(t *testing.T) {
th.sqlDB.Exec(t, "DROP SCHEDULES "+querySchedules)
require.Equal(t, 0, len(th.sqlDB.QueryStr(t, querySchedules)))
})

t.Run("pause-non-privileged-user", func(t *testing.T) {
scheduleID := makeSchedule("one-schedule", "@daily")

th.sqlDB.Exec(t, `CREATE USER testuser`)
pgURL, cleanupFunc := sqlutils.PGUrl(
t, th.server.ServingSQLAddr(), "NonPrivileged-testuser",
url.User("testuser"),
)
defer cleanupFunc()
testuser, err := gosql.Open("postgres", pgURL.String())
require.NoError(t, err)
defer testuser.Close()

_, err = testuser.Exec("PAUSE SCHEDULE $1", scheduleID)
require.EqualError(t, err, "pq: only users with the admin role are allowed to PAUSE SCHEDULES")
})
}

func TestJobsControlForSchedules(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion vendor
Submodule vendor updated 30 files
+5 −1 github.com/cockroachdb/redact/README.md
+111 −62 github.com/cockroachdb/redact/api.go
+48 −60 github.com/cockroachdb/redact/builder/builder.go
+149 −0 github.com/cockroachdb/redact/interfaces/interfaces.go
+333 −0 github.com/cockroachdb/redact/internal/buffer/buffer.go
+129 −0 github.com/cockroachdb/redact/internal/escape/escape.go
+6 −4 github.com/cockroachdb/redact/internal/fmtforward/make_format.go
+0 −83 github.com/cockroachdb/redact/internal/hooks.go
+38 −0 github.com/cockroachdb/redact/internal/markers/constants.go
+12 −22 github.com/cockroachdb/redact/internal/markers/markers.go
+0 −58 github.com/cockroachdb/redact/internal/print.go.diff
+19 −0 github.com/cockroachdb/redact/internal/redact/doc.go
+31 −10 github.com/cockroachdb/redact/internal/redact/wrappers.go
+0 −9 github.com/cockroachdb/redact/internal/rfmt/README.md
+0 −0 github.com/cockroachdb/redact/internal/rfmt/fmtsort/sort.go
+12 −18 github.com/cockroachdb/redact/internal/rfmt/format.go
+75 −0 github.com/cockroachdb/redact/internal/rfmt/format.go.diff
+160 −0 github.com/cockroachdb/redact/internal/rfmt/helpers.go
+159 −56 github.com/cockroachdb/redact/internal/rfmt/print.go
+489 −0 github.com/cockroachdb/redact/internal/rfmt/print.go.diff
+85 −0 github.com/cockroachdb/redact/internal/rfmt/printer_adapter.go
+2 −5 github.com/cockroachdb/redact/internal/rfmt/refresh.sh
+17 −2 github.com/cockroachdb/redact/internal/rfmt/registry.go
+0 −40 github.com/cockroachdb/redact/markers_internal_constants.go
+0 −217 github.com/cockroachdb/redact/markers_internal_escape.go
+0 −280 github.com/cockroachdb/redact/markers_internal_print.go
+0 −88 github.com/cockroachdb/redact/markers_internal_printer.go
+7 −42 github.com/cockroachdb/redact/markers_print.go
+3 −1 github.com/cockroachdb/redact/util.go
+10 −3 modules.txt

0 comments on commit c452a0c

Please sign in to comment.