We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cb91f43 + 47e0893 commit 343ff28Copy full SHA for 343ff28
2 files changed
src/commands/cmd_replication.cc
@@ -483,9 +483,9 @@ class CommandWait : public Commander,
483
};
484
485
REDIS_REGISTER_COMMANDS(Replication, MakeCmdAttr<CommandReplConf>("replconf", -3, "read-only no-script", NO_KEY),
486
- MakeCmdAttr<CommandPSync>("psync", -2, "read-only no-multi no-script", NO_KEY),
487
- MakeCmdAttr<CommandFetchMeta>("_fetch_meta", 1, "read-only no-multi no-script", NO_KEY),
488
- MakeCmdAttr<CommandFetchFile>("_fetch_file", 2, "read-only no-multi no-script", NO_KEY),
+ MakeCmdAttr<CommandPSync>("psync", -2, "read-only no-multi no-script admin", NO_KEY),
+ MakeCmdAttr<CommandFetchMeta>("_fetch_meta", 1, "read-only no-multi no-script admin", NO_KEY),
+ MakeCmdAttr<CommandFetchFile>("_fetch_file", 2, "read-only no-multi no-script admin", NO_KEY),
489
MakeCmdAttr<CommandDBName>("_db_name", 1, "read-only no-multi", NO_KEY),
490
MakeCmdAttr<CommandWait>("wait", 3, "read-only no-multi no-script blocking", NO_KEY), )
491
tests/gocase/integration/replication/replication_test.go
@@ -117,6 +117,36 @@ func TestReplicationWithHostname(t *testing.T) {
117
})
118
}
119
120
+func TestReplicationTransferCommandsRequireAdminPermission(t *testing.T) {
121
+ srv := util.StartServer(t, map[string]string{
122
+ "requirepass": "admin",
123
+ })
124
+ defer srv.Close()
125
+
126
+ ctx := context.Background()
127
+ adminClient := srv.NewClientWithOption(&redis.Options{Password: "admin"})
128
+ defer func() { require.NoError(t, adminClient.Close()) }()
129
130
+ require.NoError(t, adminClient.Do(ctx, "NAMESPACE", "ADD", "test_ns", "test_token").Err())
131
132
+ userClient := srv.NewClientWithOption(&redis.Options{Password: "test_token"})
133
+ defer func() { require.NoError(t, userClient.Close()) }()
134
135
+ for _, cmd := range []struct {
136
+ name string
137
+ args []interface{}
138
+ }{
139
+ {name: "PSYNC", args: []interface{}{"1"}},
140
+ {name: "_FETCH_META"},
141
+ {name: "_FETCH_FILE", args: []interface{}{"MANIFEST-000001"}},
142
+ } {
143
+ t.Run(cmd.name, func(t *testing.T) {
144
+ args := append([]interface{}{cmd.name}, cmd.args...)
145
+ require.ErrorContains(t, userClient.Do(ctx, args...).Err(), "admin permission required to perform the command")
146
147
+ }
148
+}
149
150
func TestReplicationLoading(t *testing.T) {
151
t.Parallel()
152
srvA := util.StartServer(t, map[string]string{})
0 commit comments