Commit 26a656f 1 parent 2dffd9c commit 26a656f Copy full SHA for 26a656f
File tree 3 files changed +62
-7
lines changed
3 files changed +62
-7
lines changed Original file line number Diff line number Diff line change 18
18
use Exception ;
19
19
20
20
/**
21
- <<<<<<< HEAD
22
- * Main class of PHP Toolkit
23
- =======
24
21
* Main class of SAML PHP Toolkit
25
- >>>>>>> f338e1e... Remove references to onelogin support.
26
22
*/
27
23
class Auth
28
24
{
@@ -169,14 +165,15 @@ class Auth
169
165
/**
170
166
* Initializes the SP SAML instance.
171
167
*
172
- * @param array|null $settings Setting data
168
+ * @param array|null $settings Setting data
169
+ * @param bool $spValidationOnly Validate or not the IdP data
173
170
*
174
171
* @throws Exception
175
172
* @throws Error
176
173
*/
177
- public function __construct (array $ settings = null )
174
+ public function __construct (array $ settings = null , $ spValidationOnly = false )
178
175
{
179
- $ this ->_settings = new Settings ($ settings );
176
+ $ this ->_settings = new Settings ($ settings, $ spValidationOnly );
180
177
}
181
178
182
179
/**
Original file line number Diff line number Diff line change @@ -52,6 +52,35 @@ public function testGetSettings()
52
52
$ this ->assertEquals ($ authSettings , $ settings );
53
53
}
54
54
55
+ /**
56
+ * Tests the use of the spValidationOnly at OneLogin\Saml2\Auth
57
+ *
58
+ * @covers OneLogin\Saml2\Auth
59
+ */
60
+ public function testSpValidateOnly ()
61
+ {
62
+ $ settingsDir = TEST_ROOT .'/settings/ ' ;
63
+ include $ settingsDir .'settings2.php ' ;
64
+ unset($ settingsInfo ['idp ' ]);
65
+
66
+ $ auth = new Auth ($ settingsInfo , true );
67
+ $ this ->assertEmpty ($ auth ->getErrors ());
68
+
69
+ try {
70
+ $ auth2 = new Auth ($ settingsInfo , false );
71
+ $ this ->fail ('Error was not raised ' );
72
+ } catch (Error $ e ) {
73
+ $ this ->assertContains ('idp_not_found ' , $ e ->getMessage ());
74
+ }
75
+
76
+ try {
77
+ $ auth3 = new Auth ($ settingsInfo );
78
+ $ this ->fail ('Error was not raised ' );
79
+ } catch (Error $ e ) {
80
+ $ this ->assertContains ('idp_not_found ' , $ e ->getMessage ());
81
+ }
82
+ }
83
+
55
84
/**
56
85
* Tests the getLastRequestID method of the Auth class
57
86
*
Original file line number Diff line number Diff line change @@ -51,6 +51,35 @@ public function testLoadSettingsFromArray()
51
51
$ this ->assertEmpty ($ settings3 ->getErrors ());
52
52
}
53
53
54
+ /**
55
+ * Tests the use of the spValidationOnly at OneLogin\Saml2\Settings
56
+ *
57
+ * @covers OneLogin\Saml2\Settings
58
+ */
59
+ public function testSpValidateOnly ()
60
+ {
61
+ $ settingsDir = TEST_ROOT .'/settings/ ' ;
62
+ include $ settingsDir .'settings2.php ' ;
63
+ unset($ settingsInfo ['idp ' ]);
64
+
65
+ $ settings = new Settings ($ settingsInfo , true );
66
+ $ this ->assertEmpty ($ settings ->getErrors ());
67
+
68
+ try {
69
+ $ settings2 = new Settings ($ settingsInfo , false );
70
+ $ this ->fail ('Error was not raised ' );
71
+ } catch (Error $ e ) {
72
+ $ this ->assertContains ('idp_not_found ' , $ e ->getMessage ());
73
+ }
74
+
75
+ try {
76
+ $ settings3 = new Settings ($ settingsInfo );
77
+ $ this ->fail ('Error was not raised ' );
78
+ } catch (Error $ e ) {
79
+ $ this ->assertContains ('idp_not_found ' , $ e ->getMessage ());
80
+ }
81
+ }
82
+
54
83
/**
55
84
* Tests the Settings Constructor.
56
85
* Case load setting from file
You can’t perform that action at this time.
0 commit comments