TestTLSStandalone tests TLS connection to standalone Redis
(t *testing.T)
| 9 | |
| 10 | // TestTLSStandalone tests TLS connection to standalone Redis |
| 11 | func TestTLSStandalone(t *testing.T) { |
| 12 | // Use InsecureSkipVerify for testing with self-signed certificates |
| 13 | tlsConfig := &tls.Config{ |
| 14 | InsecureSkipVerify: true, |
| 15 | } |
| 16 | |
| 17 | client := redis.NewClient(&redis.Options{ |
| 18 | Addr: "localhost:6666", |
| 19 | TLSConfig: tlsConfig, |
| 20 | }) |
| 21 | defer client.Close() |
| 22 | |
| 23 | // Test PING |
| 24 | val, err := client.Ping(ctx).Result() |
| 25 | if err != nil { |
| 26 | t.Fatalf("PING failed: %v", err) |
| 27 | } |
| 28 | if val != "PONG" { |
| 29 | t.Fatalf("Expected PONG, got %s", val) |
| 30 | } |
| 31 | |
| 32 | // Test SET/GET |
| 33 | err = client.Set(ctx, "tls_test_key", "tls_test_value", 0).Err() |
| 34 | if err != nil { |
| 35 | t.Fatalf("SET failed: %v", err) |
| 36 | } |
| 37 | |
| 38 | val, err = client.Get(ctx, "tls_test_key").Result() |
| 39 | if err != nil { |
| 40 | t.Fatalf("GET failed: %v", err) |
| 41 | } |
| 42 | if val != "tls_test_value" { |
| 43 | t.Fatalf("Expected tls_test_value, got %s", val) |
| 44 | } |
| 45 | |
| 46 | // Cleanup |
| 47 | client.Del(ctx, "tls_test_key") |
| 48 | |
| 49 | t.Log("✅ TLS standalone test passed") |
| 50 | } |
| 51 | |
| 52 | // TestTLSRedissURL tests rediss:// URL scheme |
| 53 | func TestTLSRedissURL(t *testing.T) { |