@@ -406,6 +406,49 @@ public function test_add_proxy()
406
406
], $ site ->proxies ()->all ());
407
407
}
408
408
409
+ public function test_add_multiple_proxies ()
410
+ {
411
+ $ config = Mockery::mock (Configuration::class);
412
+ $ config ->shouldReceive ('read ' )
413
+ ->andReturn (['tld ' => 'test ' , 'loopback ' => VALET_LOOPBACK ]);
414
+
415
+ swap (Configuration::class, $ config );
416
+
417
+ swap (CommandLine::class, resolve (CommandLineFake::class));
418
+
419
+ /** @var FixturesSiteFake $site */
420
+ $ site = resolve (FixturesSiteFake::class);
421
+
422
+ $ site ->useOutput ();
423
+
424
+ $ site ->assertCertificateNotExists ('my-new-proxy.com.test ' );
425
+ $ site ->assertCertificateNotExists ('my-other-new-proxy.com.test ' );
426
+ $ site ->assertNginxNotExists ('my-new-proxy.com.test ' );
427
+ $ site ->assertNginxNotExists ('my-other-new-proxy.com.test ' );
428
+
429
+ $ site ->proxyCreate ('my-new-proxy.com,my-other-new-proxy.com ' , 'https://127.0.0.1:9443 ' , true );
430
+
431
+ $ site ->assertCertificateExistsWithCounterValue ('my-new-proxy.com.test ' , 0 );
432
+ $ site ->assertCertificateExistsWithCounterValue ('my-other-new-proxy.com.test ' , 1 );
433
+ $ site ->assertNginxExists ('my-new-proxy.com.test ' );
434
+ $ site ->assertNginxExists ('my-other-new-proxy.com.test ' );
435
+
436
+ $ this ->assertEquals ([
437
+ 'my-new-proxy.com ' => [
438
+ 'site ' => 'my-new-proxy.com ' ,
439
+ 'secured ' => ' X ' ,
440
+ 'url ' => 'https://my-new-proxy.com.test ' ,
441
+ 'path ' => 'https://127.0.0.1:9443 ' ,
442
+ ],
443
+ 'my-other-new-proxy.com ' => [
444
+ 'site ' => 'my-other-new-proxy.com ' ,
445
+ 'secured ' => ' X ' ,
446
+ 'url ' => 'https://my-other-new-proxy.com.test ' ,
447
+ 'path ' => 'https://127.0.0.1:9443 ' ,
448
+ ],
449
+ ], $ site ->proxies ()->all ());
450
+ }
451
+
409
452
public function test_add_non_secure_proxy ()
410
453
{
411
454
$ config = Mockery::mock (Configuration::class);
@@ -439,6 +482,49 @@ public function test_add_non_secure_proxy()
439
482
], $ site ->proxies ()->all ());
440
483
}
441
484
485
+ public function test_add_multiple_non_secure_proxies ()
486
+ {
487
+ $ config = Mockery::mock (Configuration::class);
488
+ $ config ->shouldReceive ('read ' )
489
+ ->andReturn (['tld ' => 'test ' , 'loopback ' => VALET_LOOPBACK ]);
490
+
491
+ swap (Configuration::class, $ config );
492
+
493
+ swap (CommandLine::class, resolve (CommandLineFake::class));
494
+
495
+ /** @var FixturesSiteFake $site */
496
+ $ site = resolve (FixturesSiteFake::class);
497
+
498
+ $ site ->useOutput ();
499
+
500
+ $ site ->assertCertificateNotExists ('my-new-proxy.com.test ' );
501
+ $ site ->assertCertificateNotExists ('my-other-new-proxy.com.test ' );
502
+ $ site ->assertNginxNotExists ('my-new-proxy.com.test ' );
503
+ $ site ->assertNginxNotExists ('my-other-new-proxy.com.test ' );
504
+
505
+ $ site ->proxyCreate ('my-new-proxy.com,my-other-new-proxy.com ' , 'http://127.0.0.1:9443 ' , false );
506
+
507
+ $ site ->assertCertificateNotExists ('my-new-proxy.com.test ' );
508
+ $ site ->assertCertificateNotExists ('my-other-new-proxy.com.test ' );
509
+ $ site ->assertNginxExists ('my-new-proxy.com.test ' );
510
+ $ site ->assertNginxExists ('my-other-new-proxy.com.test ' );
511
+
512
+ $ this ->assertEquals ([
513
+ 'my-new-proxy.com ' => [
514
+ 'site ' => 'my-new-proxy.com ' ,
515
+ 'secured ' => '' ,
516
+ 'url ' => 'http://my-new-proxy.com.test ' ,
517
+ 'path ' => 'http://127.0.0.1:9443 ' ,
518
+ ],
519
+ 'my-other-new-proxy.com ' => [
520
+ 'site ' => 'my-other-new-proxy.com ' ,
521
+ 'secured ' => '' ,
522
+ 'url ' => 'http://my-other-new-proxy.com.test ' ,
523
+ 'path ' => 'http://127.0.0.1:9443 ' ,
524
+ ],
525
+ ], $ site ->proxies ()->all ());
526
+ }
527
+
442
528
public function test_add_proxy_clears_previous_proxy_certificate ()
443
529
{
444
530
$ config = Mockery::mock (Configuration::class);
@@ -565,6 +651,121 @@ public function test_remove_proxy()
565
651
$ this ->assertEquals ([], $ site ->proxies ()->all ());
566
652
}
567
653
654
+ public function test_remove_multiple_proxies ()
655
+ {
656
+ $ config = Mockery::mock (Configuration::class);
657
+ $ config ->shouldReceive ('read ' )
658
+ ->andReturn (['tld ' => 'test ' , 'loopback ' => VALET_LOOPBACK ]);
659
+
660
+ swap (Configuration::class, $ config );
661
+
662
+ swap (CommandLine::class, resolve (CommandLineFake::class));
663
+
664
+ /** @var FixturesSiteFake $site */
665
+ $ site = resolve (FixturesSiteFake::class);
666
+
667
+ $ site ->useOutput ();
668
+
669
+ $ site ->assertCertificateNotExists ('my-new-proxy.com.test ' );
670
+ $ site ->assertCertificateNotExists ('my-other-new-proxy.com.test ' );
671
+ $ site ->assertNginxNotExists ('my-new-proxy.com.test ' );
672
+ $ site ->assertNginxNotExists ('my-other-new-proxy.com.test ' );
673
+
674
+ $ this ->assertEquals ([], $ site ->proxies ()->all ());
675
+
676
+ $ site ->proxyCreate ('my-new-proxy.com,my-other-new-proxy.com ' , 'https://127.0.0.1:9443 ' , true );
677
+
678
+ $ this ->assertEquals ([
679
+ 'my-new-proxy.com ' => [
680
+ 'site ' => 'my-new-proxy.com ' ,
681
+ 'secured ' => ' X ' ,
682
+ 'url ' => 'https://my-new-proxy.com.test ' ,
683
+ 'path ' => 'https://127.0.0.1:9443 ' ,
684
+ ],
685
+ 'my-other-new-proxy.com ' => [
686
+ 'site ' => 'my-other-new-proxy.com ' ,
687
+ 'secured ' => ' X ' ,
688
+ 'url ' => 'https://my-other-new-proxy.com.test ' ,
689
+ 'path ' => 'https://127.0.0.1:9443 ' ,
690
+ ],
691
+ ], $ site ->proxies ()->all ());
692
+
693
+ $ site ->assertCertificateExists ('my-new-proxy.com.test ' );
694
+ $ site ->assertCertificateExists ('my-other-new-proxy.com.test ' );
695
+ $ site ->assertNginxExists ('my-new-proxy.com.test ' );
696
+ $ site ->assertNginxExists ('my-other-new-proxy.com.test ' );
697
+
698
+ $ site ->proxyDelete ('my-new-proxy.com,my-other-new-proxy.com ' );
699
+
700
+ $ site ->assertCertificateNotExists ('my-new-proxy.com.test ' );
701
+ $ site ->assertCertificateNotExists ('my-other-new-proxy.com.test ' );
702
+ $ site ->assertNginxNotExists ('my-new-proxy.com.test ' );
703
+ $ site ->assertNginxNotExists ('my-other-new-proxy.com.test ' );
704
+
705
+ $ this ->assertEquals ([], $ site ->proxies ()->all ());
706
+ }
707
+
708
+ public function test_remove_single_proxy_from_multiple_proxies ()
709
+ {
710
+ $ config = Mockery::mock (Configuration::class);
711
+ $ config ->shouldReceive ('read ' )
712
+ ->andReturn (['tld ' => 'test ' , 'loopback ' => VALET_LOOPBACK ]);
713
+
714
+ swap (Configuration::class, $ config );
715
+
716
+ swap (CommandLine::class, resolve (CommandLineFake::class));
717
+
718
+ /** @var FixturesSiteFake $site */
719
+ $ site = resolve (FixturesSiteFake::class);
720
+
721
+ $ site ->useOutput ();
722
+
723
+ $ site ->assertCertificateNotExists ('my-new-proxy.com.test ' );
724
+ $ site ->assertCertificateNotExists ('my-other-new-proxy.com.test ' );
725
+ $ site ->assertNginxNotExists ('my-new-proxy.com.test ' );
726
+ $ site ->assertNginxNotExists ('my-other-new-proxy.com.test ' );
727
+
728
+ $ this ->assertEquals ([], $ site ->proxies ()->all ());
729
+
730
+ $ site ->proxyCreate ('my-new-proxy.com,my-other-new-proxy.com ' , 'https://127.0.0.1:9443 ' , true );
731
+
732
+ $ this ->assertEquals ([
733
+ 'my-new-proxy.com ' => [
734
+ 'site ' => 'my-new-proxy.com ' ,
735
+ 'secured ' => ' X ' ,
736
+ 'url ' => 'https://my-new-proxy.com.test ' ,
737
+ 'path ' => 'https://127.0.0.1:9443 ' ,
738
+ ],
739
+ 'my-other-new-proxy.com ' => [
740
+ 'site ' => 'my-other-new-proxy.com ' ,
741
+ 'secured ' => ' X ' ,
742
+ 'url ' => 'https://my-other-new-proxy.com.test ' ,
743
+ 'path ' => 'https://127.0.0.1:9443 ' ,
744
+ ],
745
+ ], $ site ->proxies ()->all ());
746
+
747
+ $ site ->assertCertificateExists ('my-new-proxy.com.test ' );
748
+ $ site ->assertCertificateExists ('my-other-new-proxy.com.test ' );
749
+ $ site ->assertNginxExists ('my-new-proxy.com.test ' );
750
+ $ site ->assertNginxExists ('my-other-new-proxy.com.test ' );
751
+
752
+ $ site ->proxyDelete ('my-new-proxy.com ' );
753
+
754
+ $ site ->assertCertificateNotExists ('my-new-proxy.com.test ' );
755
+ $ site ->assertCertificateExists ('my-other-new-proxy.com.test ' );
756
+ $ site ->assertNginxNotExists ('my-new-proxy.com.test ' );
757
+ $ site ->assertNginxExists ('my-other-new-proxy.com.test ' );
758
+
759
+ $ this ->assertEquals ([
760
+ 'my-other-new-proxy.com ' => [
761
+ 'site ' => 'my-other-new-proxy.com ' ,
762
+ 'secured ' => ' X ' ,
763
+ 'url ' => 'https://my-other-new-proxy.com.test ' ,
764
+ 'path ' => 'https://127.0.0.1:9443 ' ,
765
+ ],
766
+ ], $ site ->proxies ()->all ());
767
+ }
768
+
568
769
public function test_gets_site_url_from_directory ()
569
770
{
570
771
$ config = Mockery::mock (Configuration::class);
0 commit comments