@@ -309,16 +309,15 @@ func TestValidateCreate(t *testing.T) {
309
309
test .Expect (err ).ShouldNot (HaveOccurred (), "Expected no errors on call to ValidateCreate function" )
310
310
})
311
311
312
- // Negative Test: Invalid RayCluster with EnableIngress set to true
313
- invalidRayCluster := validRayCluster .DeepCopy ()
314
-
315
312
t .Run ("Negative: Expected errors on call to ValidateCreate function due to EnableIngress set to True" , func (t * testing.T ) {
313
+ invalidRayCluster := validRayCluster .DeepCopy ()
316
314
invalidRayCluster .Spec .HeadGroupSpec .EnableIngress = support .Ptr (true )
317
315
_ , err := rcWebhook .ValidateCreate (test .Ctx (), runtime .Object (invalidRayCluster ))
318
316
test .Expect (err ).Should (HaveOccurred (), "Expected errors on call to ValidateCreate function due to EnableIngress set to True" )
319
317
})
320
318
321
319
t .Run ("Negative: Expected errors on call to ValidateCreate function due to manipulated OAuth Proxy Container" , func (t * testing.T ) {
320
+ invalidRayCluster := validRayCluster .DeepCopy ()
322
321
for i , headContainer := range invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Containers {
323
322
if headContainer .Name == oauthProxyContainerName {
324
323
invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Containers [i ].Args = []string {"--invalid-arg" }
@@ -330,6 +329,7 @@ func TestValidateCreate(t *testing.T) {
330
329
})
331
330
332
331
t .Run ("Negative: Expected errors on call to ValidateCreate function due to manipulated OAuth Proxy Volume" , func (t * testing.T ) {
332
+ invalidRayCluster := validRayCluster .DeepCopy ()
333
333
for i , headVolume := range invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Volumes {
334
334
if headVolume .Name == oauthProxyVolumeName {
335
335
invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Volumes [i ].Secret .SecretName = "invalid-secret-name"
@@ -341,6 +341,7 @@ func TestValidateCreate(t *testing.T) {
341
341
})
342
342
343
343
t .Run ("Negative: Expected errors on call to ValidateCreate function due to manipulated head group service account name" , func (t * testing.T ) {
344
+ invalidRayCluster := validRayCluster .DeepCopy ()
344
345
invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .ServiceAccountName = "invalid-service-account-name"
345
346
_ , err = rcWebhook .ValidateCreate (test .Ctx (), runtime .Object (invalidRayCluster ))
346
347
test .Expect (err ).Should (HaveOccurred (), "Expected errors on call to ValidateCreate function due to manipulated head group service account name" )
@@ -535,17 +536,15 @@ func TestValidateUpdate(t *testing.T) {
535
536
test .Expect (err ).ShouldNot (HaveOccurred (), "Expected no errors on call to ValidateUpdate function" )
536
537
})
537
538
538
- // Negative Test Cases
539
- trueBool := true
540
- invalidRayCluster := validRayCluster .DeepCopy ()
541
-
542
539
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to EnableIngress set to True" , func (t * testing.T ) {
543
- invalidRayCluster .Spec .HeadGroupSpec .EnableIngress = & trueBool
540
+ invalidRayCluster := validRayCluster .DeepCopy ()
541
+ invalidRayCluster .Spec .HeadGroupSpec .EnableIngress = support .Ptr (true )
544
542
_ , err := rcWebhook .ValidateUpdate (test .Ctx (), runtime .Object (validRayCluster ), runtime .Object (invalidRayCluster ))
545
543
test .Expect (err ).Should (HaveOccurred (), "Expected errors on call to ValidateUpdate function due to EnableIngress set to True" )
546
544
})
547
545
548
546
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to manipulated OAuth Proxy Container" , func (t * testing.T ) {
547
+ invalidRayCluster := validRayCluster .DeepCopy ()
549
548
for i , headContainer := range invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Containers {
550
549
if headContainer .Name == oauthProxyContainerName {
551
550
invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Containers [i ].Args = []string {"--invalid-arg" }
@@ -557,6 +556,7 @@ func TestValidateUpdate(t *testing.T) {
557
556
})
558
557
559
558
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to manipulated OAuth Proxy Volume" , func (t * testing.T ) {
559
+ invalidRayCluster := validRayCluster .DeepCopy ()
560
560
for i , headVolume := range invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Volumes {
561
561
if headVolume .Name == oauthProxyVolumeName {
562
562
invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Volumes [i ].Secret .SecretName = "invalid-secret-name"
@@ -568,12 +568,14 @@ func TestValidateUpdate(t *testing.T) {
568
568
})
569
569
570
570
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to manipulated head group service account name" , func (t * testing.T ) {
571
+ invalidRayCluster := validRayCluster .DeepCopy ()
571
572
invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .ServiceAccountName = "invalid-service-account-name"
572
573
_ , err := rcWebhook .ValidateUpdate (test .Ctx (), runtime .Object (validRayCluster ), runtime .Object (invalidRayCluster ))
573
574
test .Expect (err ).Should (HaveOccurred (), "Expected errors on call to ValidateUpdate function due to manipulated head group service account name" )
574
575
})
575
576
576
577
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to manipulated Init Container in the head group" , func (t * testing.T ) {
578
+ invalidRayCluster := validRayCluster .DeepCopy ()
577
579
for i , headInitContainer := range invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .InitContainers {
578
580
if headInitContainer .Name == "create-cert" {
579
581
invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .InitContainers [i ].Command = []string {"manipulated command" }
@@ -585,6 +587,7 @@ func TestValidateUpdate(t *testing.T) {
585
587
})
586
588
587
589
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to manipulated Init Container in the worker group" , func (t * testing.T ) {
590
+ invalidRayCluster := validRayCluster .DeepCopy ()
588
591
for _ , workerGroup := range invalidRayCluster .Spec .WorkerGroupSpecs {
589
592
for i , workerInitContainer := range workerGroup .Template .Spec .InitContainers {
590
593
if workerInitContainer .Name == "create-cert" {
@@ -598,6 +601,7 @@ func TestValidateUpdate(t *testing.T) {
598
601
})
599
602
600
603
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to manipulated Volume in the head group" , func (t * testing.T ) {
604
+ invalidRayCluster := validRayCluster .DeepCopy ()
601
605
for i , headVolume := range invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Volumes {
602
606
if headVolume .Name == "ca-vol" {
603
607
invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Volumes [i ].Secret .SecretName = "invalid-secret-name"
@@ -609,6 +613,7 @@ func TestValidateUpdate(t *testing.T) {
609
613
})
610
614
611
615
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to manipulated Volume in the worker group" , func (t * testing.T ) {
616
+ invalidRayCluster := validRayCluster .DeepCopy ()
612
617
for _ , workerGroup := range invalidRayCluster .Spec .WorkerGroupSpecs {
613
618
for i , workerVolume := range workerGroup .Template .Spec .Volumes {
614
619
if workerVolume .Name == "ca-vol" {
@@ -622,6 +627,7 @@ func TestValidateUpdate(t *testing.T) {
622
627
})
623
628
624
629
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to manipulated env vars in the head group" , func (t * testing.T ) {
630
+ invalidRayCluster := validRayCluster .DeepCopy ()
625
631
for i , headEnvVar := range invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Containers [0 ].Env {
626
632
if headEnvVar .Name == "RAY_USE_TLS" {
627
633
invalidRayCluster .Spec .HeadGroupSpec .Template .Spec .Containers [0 ].Env [i ].Value = "invalid-value"
@@ -633,6 +639,7 @@ func TestValidateUpdate(t *testing.T) {
633
639
})
634
640
635
641
t .Run ("Negative: Expected errors on call to ValidateUpdate function due to manipulated env vars in the worker group" , func (t * testing.T ) {
642
+ invalidRayCluster := validRayCluster .DeepCopy ()
636
643
for _ , workerGroup := range invalidRayCluster .Spec .WorkerGroupSpecs {
637
644
for i , workerEnvVar := range workerGroup .Template .Spec .Containers [0 ].Env {
638
645
if workerEnvVar .Name == "RAY_USE_TLS" {
0 commit comments