@@ -26,6 +26,8 @@ import (
2626 "github.com/google/go-cmp/cmp"
2727 "github.com/stretchr/testify/assert"
2828
29+ configv1 "github.com/openshift/api/config/v1"
30+
2931 argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1"
3032)
3133
@@ -3134,3 +3136,104 @@ func TestReconcileArgoCD_reconcileRedisDeployment_customLabelsAndAnnotations(t *
31343136 assert .False (t , hasCustomAnnotation )
31353137 assert .False (t , hasCustomLabel )
31363138}
3139+
3140+ func TestBuildRedisArgs (t * testing.T ) {
3141+ tests := []struct {
3142+ name string
3143+ centralTLS TLSConfigProfile
3144+ expected []string
3145+ wantErr bool
3146+ }{
3147+ {
3148+ name : "central TLS config with invalid min version" ,
3149+ centralTLS : TLSConfigProfile {
3150+ MinVersion : configv1 .TLSProtocolVersion ("INVALID" ),
3151+ },
3152+ expected : nil ,
3153+ wantErr : false ,
3154+ },
3155+ {
3156+ name : "central TLS config with tls 1.2" ,
3157+ centralTLS : TLSConfigProfile {
3158+ MinVersion : configv1 .VersionTLS12 ,
3159+ Ciphers : []string {
3160+ "ECDHE-RSA-AES128-GCM-SHA256" ,
3161+ },
3162+ },
3163+ expected : []string {
3164+ "--tls-protocols" ,
3165+ "TLSv1.2" ,
3166+ "--tls-ciphers" ,
3167+ "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ,
3168+ "--tls-ciphersuites" ,
3169+ "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ,
3170+ },
3171+ wantErr : false ,
3172+ },
3173+ {
3174+ name : "central TLS config with tls 1.3" ,
3175+ centralTLS : TLSConfigProfile {
3176+ MinVersion : configv1 .VersionTLS13 ,
3177+ Ciphers : []string {
3178+ "TLS_AES_128_GCM_SHA256" ,
3179+ },
3180+ },
3181+ expected : []string {
3182+ "--tls-protocols" ,
3183+ "TLSv1.3" ,
3184+ "--tls-ciphersuites" ,
3185+ "TLS_AES_128_GCM_SHA256" ,
3186+ },
3187+ wantErr : false ,
3188+ },
3189+ {
3190+ name : "central TLS config only version" ,
3191+ centralTLS : TLSConfigProfile {
3192+ MinVersion : configv1 .VersionTLS12 ,
3193+ },
3194+ expected : []string {
3195+ "--tls-protocols" ,
3196+ "TLSv1.2" ,
3197+ },
3198+ wantErr : false ,
3199+ },
3200+ {
3201+ name : "central TLS config only ciphers" ,
3202+ centralTLS : TLSConfigProfile {
3203+ Ciphers : []string {
3204+ "ECDHE-RSA-AES256-GCM-SHA384" ,
3205+ },
3206+ },
3207+ expected : []string {
3208+ "--tls-ciphers" ,
3209+ "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" ,
3210+ "--tls-ciphersuites" ,
3211+ "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" ,
3212+ },
3213+ wantErr : false ,
3214+ },
3215+ {
3216+ name : "central TLS config with unmapped cipher" ,
3217+ centralTLS : TLSConfigProfile {
3218+ MinVersion : configv1 .VersionTLS12 ,
3219+ Ciphers : []string {
3220+ "INVALID" ,
3221+ },
3222+ },
3223+ expected : []string {
3224+ "--tls-protocols" ,
3225+ "TLSv1.2" ,
3226+ },
3227+ wantErr : false ,
3228+ },
3229+ }
3230+
3231+ for _ , tt := range tests {
3232+ t .Run (tt .name , func (t * testing.T ) {
3233+ got := BuildRedisArgsFromClusterTLSProfile (tt .centralTLS )
3234+ if ! reflect .DeepEqual (got , tt .expected ) {
3235+ t .Fatalf ("expected %#v got %#v" , tt .expected , got )
3236+ }
3237+ })
3238+ }
3239+ }
0 commit comments