@@ -892,6 +892,50 @@ public function testFinishClientAuthorizationThrowsErrorIfNoMatchingUri()
892892 }
893893 }
894894
895+ public function testFinishClientAuthorizationThrowsErrorIfNoMatchingDomain ()
896+ {
897+ $ stub = new OAuth2GrantCodeStub ;
898+ $ stub ->addClient (new OAuth2Client ('blah ' , 'foo ' , array ('http://a.example.com ' )));
899+ $ oauth2 = new OAuth2 ($ stub );
900+
901+ $ data = new \stdClass ;
902+
903+ try {
904+ $ oauth2 ->finishClientAuthorization (true , $ data , new Request (array (
905+ 'client_id ' => 'blah ' ,
906+ 'response_type ' => 'code ' ,
907+ 'state ' => '42 ' ,
908+ 'redirect_uri ' => 'http://a.example.com.test.com/ ' ,
909+ )));
910+ $ this ->fail ('The expected exception OAuth2ServerException was not thrown ' );
911+ } catch (OAuth2ServerException $ e ) {
912+ $ this ->assertSame ('redirect_uri_mismatch ' , $ e ->getMessage ());
913+ $ this ->assertSame ('The redirect URI provided does not match registered URI(s). ' , $ e ->getDescription ());
914+ }
915+ }
916+
917+ public function testFinishClientAuthorizationThrowsErrorIfNoMatchingPort ()
918+ {
919+ $ stub = new OAuth2GrantCodeStub ;
920+ $ stub ->addClient (new OAuth2Client ('blah ' , 'foo ' , array ('http://a.example.com:80 ' )));
921+ $ oauth2 = new OAuth2 ($ stub );
922+
923+ $ data = new \stdClass ;
924+
925+ try {
926+ $ oauth2 ->finishClientAuthorization (true , $ data , new Request (array (
927+ 'client_id ' => 'blah ' ,
928+ 'response_type ' => 'code ' ,
929+ 'state ' => '42 ' ,
930+ 'redirect_uri ' => 'http://a.example.com:8080/ ' ,
931+ )));
932+ $ this ->fail ('The expected exception OAuth2ServerException was not thrown ' );
933+ } catch (OAuth2ServerException $ e ) {
934+ $ this ->assertSame ('redirect_uri_mismatch ' , $ e ->getMessage ());
935+ $ this ->assertSame ('The redirect URI provided does not match registered URI(s). ' , $ e ->getDescription ());
936+ }
937+ }
938+
895939 public function testFinishClientAuthorizationThrowsErrorIfRedirectUriAttemptsPathTraversal ()
896940 {
897941 $ stub = new OAuth2GrantCodeStub ;
0 commit comments