@@ -633,46 +633,6 @@ public function test_get_request_login_url_user_parameters_based_on_plugin_confi
633
633
set_config ('updateuser ' , false , 'auth_userkey ' );
634
634
}
635
635
636
- /**
637
- * Test that we can validate keylifetime for config form correctly.
638
- */
639
- public function test_validate_keylifetime_for_config_form () {
640
- $ form = new stdClass ();
641
-
642
- $ form ->redirecturl = '' ;
643
- $ form ->ssourl = '' ;
644
-
645
- $ form ->keylifetime = '' ;
646
- $ err = array ();
647
- $ this ->auth ->validate_form ($ form , $ err );
648
- $ this ->assertEquals ('User key life time should be a number ' , $ err ['keylifetime ' ]);
649
-
650
- $ form ->keylifetime = '0 ' ;
651
- $ err = array ();
652
- $ this ->auth ->validate_form ($ form , $ err );
653
- $ this ->assertEquals ('User key life time should be a number ' , $ err ['keylifetime ' ]);
654
-
655
- $ form ->keylifetime = '1 ' ;
656
- $ err = array ();
657
- $ this ->auth ->validate_form ($ form , $ err );
658
- $ this ->assertFalse (array_key_exists ('keylifetime ' , $ err ));
659
-
660
- $ form ->keylifetime = 0 ;
661
- $ err = array ();
662
- $ this ->auth ->validate_form ($ form , $ err );
663
- $ this ->assertEquals ('User key life time should be a number ' , $ err ['keylifetime ' ]);
664
-
665
- $ form ->keylifetime = 1 ;
666
- $ err = array ();
667
- $ this ->auth ->validate_form ($ form , $ err );
668
- $ this ->assertFalse (array_key_exists ('keylifetime ' , $ err ));
669
-
670
- $ form ->keylifetime = 'rkjflj ' ;
671
- $ err = array ();
672
- $ this ->auth ->validate_form ($ form , $ err );
673
- $ this ->assertEquals ('User key life time should be a number ' , $ err ['keylifetime ' ]);
674
- }
675
-
676
636
/**
677
637
* Data provider for testing URL validation functions.
678
638
*
@@ -693,98 +653,6 @@ public function url_data_provider() {
693
653
);
694
654
}
695
655
696
- /**
697
- * Test that we can validate redirecturl for config form correctly.
698
- *
699
- * @dataProvider url_data_provider
700
- */
701
-
702
- /**
703
- * Test that we can validate redirecturl for config form correctly.
704
- *
705
- * @dataProvider url_data_provider
706
- *
707
- * @param string $url URL to test.
708
- * @param string $errortext Expected error text.
709
- */
710
- public function test_validate_redirecturl_for_config_form ($ url , $ errortext ) {
711
- $ form = new stdClass ();
712
-
713
- $ form ->keylifetime = 10 ;
714
- $ form ->ssourl = '' ;
715
-
716
- $ form ->redirecturl = $ url ;
717
- $ err = array ();
718
- $ this ->auth ->validate_form ($ form , $ err );
719
-
720
- if (empty ($ errortext )) {
721
- $ this ->assertFalse (array_key_exists ('redirecturl ' , $ err ));
722
- } else {
723
- $ this ->assertArrayHasKey ('redirecturl ' , $ err );
724
- $ this ->assertEquals ($ errortext , $ err ['redirecturl ' ]);
725
- }
726
- }
727
-
728
- /**
729
- * Test that we can validate ssourl for config form correctly.
730
- *
731
- * @dataProvider url_data_provider
732
- *
733
- * @param string $url URL to test.
734
- * @param string $errortext Expected error text.
735
- */
736
- public function test_validate_ssourl_for_config_form ($ url , $ errortext ) {
737
- $ form = new stdClass ();
738
-
739
- $ form ->keylifetime = 10 ;
740
- $ form ->redirecturl = '' ;
741
- $ form ->ssourl = '' ;
742
-
743
- $ form ->ssourl = $ url ;
744
- $ err = array ();
745
- $ this ->auth ->validate_form ($ form , $ err );
746
-
747
- if (empty ($ errortext )) {
748
- $ this ->assertFalse (array_key_exists ('ssourl ' , $ err ));
749
- } else {
750
- $ this ->assertArrayHasKey ('ssourl ' , $ err );
751
- $ this ->assertEquals ($ errortext , $ err ['ssourl ' ]);
752
- }
753
- }
754
-
755
- /**
756
- * Test that we can process config form.
757
- */
758
- public function test_process_config_form () {
759
- $ config = get_config ('auth_userkey ' );
760
-
761
- $ this ->assertObjectNotHasAttribute ('mappingfield ' , $ config );
762
- $ this ->assertObjectNotHasAttribute ('keylifetime ' , $ config );
763
- $ this ->assertObjectNotHasAttribute ('iprestriction ' , $ config );
764
-
765
- $ formconfig = new stdClass ();
766
- $ formconfig ->mappingfield = 'email ' ;
767
- $ formconfig ->keylifetime = 100 ;
768
- $ formconfig ->iprestriction = 0 ;
769
- $ formconfig ->ipwhitelist = '' ;
770
- $ formconfig ->redirecturl = 'http://google.com/ ' ;
771
- $ formconfig ->ssourl = 'http://google.com/ ' ;
772
- $ formconfig ->createuser = false ;
773
- $ formconfig ->updateuser = false ;
774
-
775
- $ this ->auth ->process_config ($ formconfig );
776
-
777
- $ config = get_config ('auth_userkey ' );
778
- $ this ->assertObjectHasAttribute ('mappingfield ' , $ config );
779
- $ this ->assertObjectHasAttribute ('keylifetime ' , $ config );
780
- $ this ->assertObjectHasAttribute ('iprestriction ' , $ config );
781
-
782
- $ this ->assertEquals ('email ' , $ config ->mappingfield );
783
- $ this ->assertEquals (100 , $ config ->keylifetime );
784
- $ this ->assertEquals (0 , $ config ->iprestriction );
785
- $ this ->assertEquals ('http://google.com/ ' , $ config ->redirecturl );
786
- }
787
-
788
656
/**
789
657
* Test required parameter exception gets thrown id try to login, but key is not set.
790
658
*
0 commit comments