Skip to content

Commit 7dcb49a

Browse files
authored
Merge branch 'master' into norm-credential-provider
2 parents c97226c + 6871741 commit 7dcb49a

File tree

10 files changed

+113
-61
lines changed

10 files changed

+113
-61
lines changed

.github/actions/run-tests/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ runs:
2525
2626
# Mapping of redis version to redis testing containers
2727
declare -A redis_version_mapping=(
28-
["8.0.1"]="8.0.1-pre"
29-
["7.4.2"]="rs-7.4.0-v2"
30-
["7.2.7"]="rs-7.2.0-v14"
28+
["8.0.x"]="8.0.2"
29+
["7.4.x"]="rs-7.4.0-v5"
30+
["7.2.x"]="rs-7.2.0-v17"
3131
)
3232
3333
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
redis-version:
21-
- "8.0.1" # 8.0.1
22-
- "7.4.2" # should use redis stack 7.4
21+
- "8.0.x" # Redis CE 8.0
22+
- "7.4.x" # Redis stack 7.4
2323
go-version:
2424
- "1.23.x"
2525
- "1.24.x"
@@ -43,8 +43,8 @@ jobs:
4343
4444
# Mapping of redis version to redis testing containers
4545
declare -A redis_version_mapping=(
46-
["8.0.1"]="8.0.1-pre"
47-
["7.4.2"]="rs-7.4.0-v2"
46+
["8.0.x"]="8.0.2"
47+
["7.4.x"]="rs-7.4.0-v5"
4848
)
4949
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
5050
echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV
@@ -72,9 +72,9 @@ jobs:
7272
fail-fast: false
7373
matrix:
7474
redis-version:
75-
- "8.0.1" # 8.0.1
76-
- "7.4.2" # should use redis stack 7.4
77-
- "7.2.7" # should redis stack 7.2
75+
- "8.0.x" # Redis CE 8.0
76+
- "7.4.x" # Redis stack 7.4
77+
- "7.2.x" # Redis stack 7.2
7878
go-version:
7979
- "1.23.x"
8080
- "1.24.x"

.github/workflows/doctests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
services:
1818
redis-stack:
19-
image: redislabs/client-libs-test:8.0.1-pre
19+
image: redislabs/client-libs-test:8.0.2
2020
env:
2121
TLS_ENABLED: no
2222
REDIS_CLUSTER: no

auth/auth_test.go

Lines changed: 84 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package auth
22

33
import (
44
"errors"
5+
"strings"
56
"sync"
67
"testing"
78
"time"
@@ -179,36 +180,90 @@ func TestStreamingCredentialsProvider(t *testing.T) {
179180
}
180181

181182
func TestBasicCredentials(t *testing.T) {
182-
t.Run("basic auth", func(t *testing.T) {
183-
creds := NewBasicCredentials("user1", "pass1")
184-
username, password := creds.BasicAuth()
185-
if username != "user1" {
186-
t.Fatalf("expected username 'user1', got '%s'", username)
187-
}
188-
if password != "pass1" {
189-
t.Fatalf("expected password 'pass1', got '%s'", password)
190-
}
191-
})
192-
193-
t.Run("raw credentials", func(t *testing.T) {
194-
creds := NewBasicCredentials("user1", "pass1")
195-
raw := creds.RawCredentials()
196-
expected := "user1:pass1"
197-
if raw != expected {
198-
t.Fatalf("expected raw credentials '%s', got '%s'", expected, raw)
199-
}
200-
})
183+
tests := []struct {
184+
name string
185+
username string
186+
password string
187+
expectedUser string
188+
expectedPass string
189+
expectedRaw string
190+
}{
191+
{
192+
name: "basic auth",
193+
username: "user1",
194+
password: "pass1",
195+
expectedUser: "user1",
196+
expectedPass: "pass1",
197+
expectedRaw: "user1:pass1",
198+
},
199+
{
200+
name: "empty username",
201+
username: "",
202+
password: "pass1",
203+
expectedUser: "",
204+
expectedPass: "pass1",
205+
expectedRaw: ":pass1",
206+
},
207+
{
208+
name: "empty password",
209+
username: "user1",
210+
password: "",
211+
expectedUser: "user1",
212+
expectedPass: "",
213+
expectedRaw: "user1:",
214+
},
215+
{
216+
name: "both username and password empty",
217+
username: "",
218+
password: "",
219+
expectedUser: "",
220+
expectedPass: "",
221+
expectedRaw: ":",
222+
},
223+
{
224+
name: "special characters",
225+
username: "user:1",
226+
password: "pa:ss@!#",
227+
expectedUser: "user:1",
228+
expectedPass: "pa:ss@!#",
229+
expectedRaw: "user:1:pa:ss@!#",
230+
},
231+
{
232+
name: "unicode characters",
233+
username: "ユーザー",
234+
password: "密碼123",
235+
expectedUser: "ユーザー",
236+
expectedPass: "密碼123",
237+
expectedRaw: "ユーザー:密碼123",
238+
},
239+
{
240+
name: "long credentials",
241+
username: strings.Repeat("u", 1000),
242+
password: strings.Repeat("p", 1000),
243+
expectedUser: strings.Repeat("u", 1000),
244+
expectedPass: strings.Repeat("p", 1000),
245+
expectedRaw: strings.Repeat("u", 1000) + ":" + strings.Repeat("p", 1000),
246+
},
247+
}
201248

202-
t.Run("empty username", func(t *testing.T) {
203-
creds := NewBasicCredentials("", "pass1")
204-
username, password := creds.BasicAuth()
205-
if username != "" {
206-
t.Fatalf("expected empty username, got '%s'", username)
207-
}
208-
if password != "pass1" {
209-
t.Fatalf("expected password 'pass1', got '%s'", password)
210-
}
211-
})
249+
for _, tt := range tests {
250+
t.Run(tt.name, func(t *testing.T) {
251+
creds := NewBasicCredentials(tt.username, tt.password)
252+
253+
user, pass := creds.BasicAuth()
254+
if user != tt.expectedUser {
255+
t.Errorf("BasicAuth() username = %q; want %q", user, tt.expectedUser)
256+
}
257+
if pass != tt.expectedPass {
258+
t.Errorf("BasicAuth() password = %q; want %q", pass, tt.expectedPass)
259+
}
260+
261+
raw := creds.RawCredentials()
262+
if raw != tt.expectedRaw {
263+
t.Errorf("RawCredentials() = %q; want %q", raw, tt.expectedRaw)
264+
}
265+
})
266+
}
212267
}
213268

214269
func TestReAuthCredentialsListener(t *testing.T) {

osscluster.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -979,13 +979,6 @@ func (c *ClusterClient) Close() error {
979979
return c.nodes.Close()
980980
}
981981

982-
// Do create a Cmd from the args and processes the cmd.
983-
func (c *ClusterClient) Do(ctx context.Context, args ...interface{}) *Cmd {
984-
cmd := NewCmd(ctx, args...)
985-
_ = c.Process(ctx, cmd)
986-
return cmd
987-
}
988-
989982
func (c *ClusterClient) Process(ctx context.Context, cmd Cmder) error {
990983
err := c.processHook(ctx, cmd)
991984
cmd.SetErr(err)

osscluster_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ var _ = Describe("ClusterClient", func() {
264264
var client *redis.ClusterClient
265265

266266
assertClusterClient := func() {
267+
It("do", func() {
268+
val, err := client.Do(ctx, "ping").Result()
269+
Expect(err).NotTo(HaveOccurred())
270+
Expect(val).To(Equal("PONG"))
271+
})
272+
267273
It("should GET/SET/DEL", func() {
268274
err := client.Get(ctx, "A").Err()
269275
Expect(err).To(Equal(redis.Nil))

redis.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -776,13 +776,6 @@ func (c *Client) Conn() *Conn {
776776
return newConn(c.opt, pool.NewStickyConnPool(c.connPool), &c.hooksMixin)
777777
}
778778

779-
// Do create a Cmd from the args and processes the cmd.
780-
func (c *Client) Do(ctx context.Context, args ...interface{}) *Cmd {
781-
cmd := NewCmd(ctx, args...)
782-
_ = c.Process(ctx, cmd)
783-
return cmd
784-
}
785-
786779
func (c *Client) Process(ctx context.Context, cmd Cmder) error {
787780
err := c.processHook(ctx, cmd)
788781
cmd.SetErr(err)

redis_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ var _ = Describe("Client", func() {
8989
Expect(err).NotTo(HaveOccurred())
9090
})
9191

92+
It("do", func() {
93+
val, err := client.Do(ctx, "ping").Result()
94+
Expect(err).NotTo(HaveOccurred())
95+
Expect(val).To(Equal("PONG"))
96+
})
97+
9298
It("should ping", func() {
9399
val, err := client.Ping(ctx).Result()
94100
Expect(err).NotTo(HaveOccurred())

ring.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,6 @@ func (c *Ring) SetAddrs(addrs map[string]string) {
565565
c.sharding.SetAddrs(addrs)
566566
}
567567

568-
// Do create a Cmd from the args and processes the cmd.
569-
func (c *Ring) Do(ctx context.Context, args ...interface{}) *Cmd {
570-
cmd := NewCmd(ctx, args...)
571-
_ = c.Process(ctx, cmd)
572-
return cmd
573-
}
574-
575568
func (c *Ring) Process(ctx context.Context, cmd Cmder) error {
576569
err := c.processHook(ctx, cmd)
577570
cmd.SetErr(err)

ring_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ var _ = Describe("Redis Ring", func() {
7474
Expect(ring.Close()).NotTo(HaveOccurred())
7575
})
7676

77+
It("do", func() {
78+
val, err := ring.Do(ctx, "ping").Result()
79+
Expect(err).NotTo(HaveOccurred())
80+
Expect(val).To(Equal("PONG"))
81+
})
82+
7783
It("supports context", func() {
7884
ctx, cancel := context.WithCancel(ctx)
7985
cancel()

0 commit comments

Comments
 (0)