MediaWiki  1.30.0
AuthenticationResponseTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Auth;
4 
16  public function testConstructors( $constructor, $args, $expect ) {
17  if ( is_array( $expect ) ) {
19  $res->messageType = 'warning';
20  foreach ( $expect as $field => $value ) {
21  $res->$field = $value;
22  }
23  $ret = call_user_func_array( "MediaWiki\\Auth\\AuthenticationResponse::$constructor", $args );
24  $this->assertEquals( $res, $ret );
25  } else {
26  try {
27  call_user_func_array( "MediaWiki\\Auth\\AuthenticationResponse::$constructor", $args );
28  $this->fail( 'Expected exception not thrown' );
29  } catch ( \Exception $ex ) {
30  $this->assertEquals( $expect, $ex );
31  }
32  }
33  }
34 
35  public function provideConstructors() {
36  $req = $this->getMockForAbstractClass( AuthenticationRequest::class );
37  $msg = new \Message( 'mainpage' );
38 
39  return [
40  [ 'newPass', [], [
41  'status' => AuthenticationResponse::PASS,
42  ] ],
43  [ 'newPass', [ 'name' ], [
44  'status' => AuthenticationResponse::PASS,
45  'username' => 'name',
46  ] ],
47  [ 'newPass', [ 'name', null ], [
48  'status' => AuthenticationResponse::PASS,
49  'username' => 'name',
50  ] ],
51 
52  [ 'newFail', [ $msg ], [
53  'status' => AuthenticationResponse::FAIL,
54  'message' => $msg,
55  'messageType' => 'error',
56  ] ],
57 
58  [ 'newRestart', [ $msg ], [
60  'message' => $msg,
61  ] ],
62 
63  [ 'newAbstain', [], [
65  ] ],
66 
67  [ 'newUI', [ [ $req ], $msg ], [
68  'status' => AuthenticationResponse::UI,
69  'neededRequests' => [ $req ],
70  'message' => $msg,
71  'messageType' => 'warning',
72  ] ],
73 
74  [ 'newUI', [ [ $req ], $msg, 'warning' ], [
75  'status' => AuthenticationResponse::UI,
76  'neededRequests' => [ $req ],
77  'message' => $msg,
78  'messageType' => 'warning',
79  ] ],
80 
81  [ 'newUI', [ [ $req ], $msg, 'error' ], [
82  'status' => AuthenticationResponse::UI,
83  'neededRequests' => [ $req ],
84  'message' => $msg,
85  'messageType' => 'error',
86  ] ],
87  [ 'newUI', [ [], $msg ],
88  new \InvalidArgumentException( '$reqs may not be empty' )
89  ],
90 
91  [ 'newRedirect', [ [ $req ], 'http://example.org/redir' ], [
93  'neededRequests' => [ $req ],
94  'redirectTarget' => 'http://example.org/redir',
95  ] ],
96  [
97  'newRedirect',
98  [ [ $req ], 'http://example.org/redir', [ 'foo' => 'bar' ] ],
99  [
101  'neededRequests' => [ $req ],
102  'redirectTarget' => 'http://example.org/redir',
103  'redirectApiData' => [ 'foo' => 'bar' ],
104  ]
105  ],
106  [ 'newRedirect', [ [], 'http://example.org/redir' ],
107  new \InvalidArgumentException( '$reqs may not be empty' )
108  ],
109  ];
110  }
111 
112 }
MediaWiki\Auth\AuthenticationResponseTest\provideConstructors
provideConstructors()
Definition: AuthenticationResponseTest.php:35
$req
this hook is for auditing only $req
Definition: hooks.txt:988
MediaWiki\Auth\AuthenticationResponse\RESTART
const RESTART
Indicates that third-party authentication succeeded but no user exists.
Definition: AuthenticationResponse.php:49
$res
$res
Definition: database.txt:21
MediaWiki\Auth\AuthenticationResponseTest\testConstructors
testConstructors( $constructor, $args, $expect)
provideConstructors
Definition: AuthenticationResponseTest.php:16
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWiki\Auth\AuthenticationResponse\UI
const UI
Indicates that the authentication needs further user input of some sort.
Definition: AuthenticationResponse.php:55
MediaWiki\Auth\AuthenticationResponse\REDIRECT
const REDIRECT
Indicates that the authentication needs to be redirected to a third party to proceed.
Definition: AuthenticationResponse.php:58
MediaWikiTestCase
Definition: MediaWikiTestCase.php:15
MediaWiki\Auth\AuthenticationResponse
This is a value object to hold authentication response data.
Definition: AuthenticationResponse.php:37
MediaWiki\Auth\AuthenticationResponse\ABSTAIN
const ABSTAIN
Indicates that the authentication provider does not handle this request.
Definition: AuthenticationResponse.php:52
MediaWiki\Auth\AuthenticationResponse\FAIL
const FAIL
Indicates that the authentication failed.
Definition: AuthenticationResponse.php:42
$value
$value
Definition: styleTest.css.php:45
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1965
$args
if( $line===false) $args
Definition: cdb.php:63
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
MediaWiki\Auth\AuthenticationResponseTest
AuthManager MediaWiki\Auth\AuthenticationResponse.
Definition: AuthenticationResponseTest.php:9
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
MediaWiki\Auth\AuthenticationResponse\PASS
const PASS
Indicates that the authentication succeeded.
Definition: AuthenticationResponse.php:39
MediaWiki\Auth
Definition: AbstractAuthenticationProvider.php:22