Code development platform for open source projects from the European Union institutions

Commit 8230fe95 authored by Pol Dellaiera's avatar Pol Dellaiera
Browse files

tests: convert `XML` in `JSON`

parent 27969553
Loading
Loading
Loading
Loading
+105 −83
Original line number Diff line number Diff line
@@ -32,22 +32,25 @@ class CasHelper
                case 'http://local/cas/serviceValidate?ticket=PT-ticket&service=http%3A%2F%2Flocal%2Fcas%2FproxyValidate%3Fservice%3Dservice':
                case 'http://local/cas/serviceValidate?ticket=PT-ticket&service=http%3A%2F%2Ffrom':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                         <cas:authenticationSuccess>
                          <cas:user>username</cas:user>
                          <cas:authenticationLevel>MEDIUM</cas:authenticationLevel>
                         </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "authenticationLevel": "MEDIUM"
                                }
                            }
                        }
                        EOF;

                    break;

                case 'http://local/cas/serviceValidate?service=service&ticket=ticket-failure':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                         <cas:authenticationFailure>
                         </cas:authenticationFailure>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationFailure": {}
                            }
                        }
                        EOF;

                    break;
@@ -60,95 +63,109 @@ class CasHelper
                case 'http://local/cas/proxyValidate?service=http%3A%2F%2Flocal%2Fcas%2FserviceValidate%3Fservice%3Dservice&ticket=ticket':
                case 'http://local/cas/proxyValidate?service=http%3A%2F%2Flocal%2Fcas%2FserviceValidate%3Fservice%3Dservice%26renew%3Dtrue&ticket=ticket&renew=true':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                         <cas:authenticationSuccess>
                          <cas:user>username</cas:user>
                          <cas:proxies>
                            <cas:proxy>http://app/proxyCallback.php</cas:proxy>
                          </cas:proxies>
                         </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "proxies": [
                                        "http://app/proxyCallback.php"
                                    ]
                                }
                            }
                        }
                        EOF;

                    break;

                case 'http://local/cas/serviceValidate?service=service&ticket=authenticationLevel_feature_success':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                         <cas:authenticationSuccess>
                          <cas:user>username</cas:user>
                          <cas:proxies>
                            <cas:proxy>http://app/proxyCallback.php</cas:proxy>
                          </cas:proxies>
                          <cas:authenticationLevel>MEDIUM</cas:authenticationLevel>
                         </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "authenticationLevel": "MEDIUM",
                                    "proxies": [
                                        "http://app/proxyCallback.php"
                                    ]
                                }
                            }
                        }
                        EOF;

                    break;

                case 'http://local/cas/serviceValidate?service=service&ticket=authenticationLevel_high':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                            <cas:authenticationSuccess>
                            <cas:user>username</cas:user>
                            <cas:proxies>
                            <cas:proxy>http://app/proxyCallback.php</cas:proxy>
                            </cas:proxies>
                            <cas:authenticationLevel>HIGH</cas:authenticationLevel>
                            </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "authenticationLevel": "HIGH",
                                    "proxies": [
                                        "http://app/proxyCallback.php"
                                    ]
                                }
                            }
                        }
                        EOF;

                    break;

                case 'http://local/cas/serviceValidate?service=service&ticket=authenticationLevel_basic':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                            <cas:authenticationSuccess>
                            <cas:user>username</cas:user>
                            <cas:proxies>
                            <cas:proxy>http://app/proxyCallback.php</cas:proxy>
                            </cas:proxies>
                            <cas:authenticationLevel>BASIC</cas:authenticationLevel>
                            </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "authenticationLevel": "BASIC",
                                    "proxies": [
                                        "http://app/proxyCallback.php"
                                    ]
                                }
                            }
                        }
                        EOF;

                    break;

                case 'http://local/cas/serviceValidate?ticket=ST-ticket-pgt&service=http%3A%2F%2Ffrom':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                         <cas:authenticationSuccess>
                          <cas:user>username</cas:user>
                          <cas:proxyGrantingTicket>pgtIou</cas:proxyGrantingTicket>
                         </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "proxyGrantingTicket": "pgtIou"
                                }
                            }
                        }
                        EOF;

                    break;

                case 'http://local/cas/serviceValidate?ticket=ST-ticket-pgt-pgtiou-not-found&service=http%3A%2F%2Ffrom':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                         <cas:authenticationSuccess>
                          <cas:user>username</cas:user>
                          <cas:proxyGrantingTicket>unknownPgtIou</cas:proxyGrantingTicket>
                         </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "proxyGrantingTicket": "unknownPgtIou"
                                }
                            }
                        }
                        EOF;

                    break;

                case 'http://local/cas/proxyValidate?ticket=ST-ticket-pgt-pgtiou-pgtid-null&service=http%3A%2F%2Ffrom':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                         <cas:authenticationSuccess>
                          <cas:user>username</cas:user>
                          <cas:proxyGrantingTicket>pgtIouWithPgtIdNull</cas:proxyGrantingTicket>
                         </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "proxyGrantingTicket": "pgtIouWithPgtIdNull"
                                }
                            }
                        }
                        EOF;

                    break;
@@ -157,15 +174,18 @@ class CasHelper
                case 'http://local/cas/proxyValidate?ticket=ST-ticket-pgt&service=http%3A%2F%2Ffrom':
                case 'http://local/cas/proxyValidate?service=http%3A%2F%2Flocal%2Fcas%2FproxyValidate%3Fservice%3Dhttp%253A%252F%252Ffrom&ticket=PT-ticket-pgt':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                         <cas:authenticationSuccess>
                          <cas:user>username</cas:user>
                          <cas:proxyGrantingTicket>pgtIou</cas:proxyGrantingTicket>
                          <cas:proxies>
                            <cas:proxy>http://app/proxyCallback.php</cas:proxy>
                          </cas:proxies>
                         </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "authenticationLevel": "HIGH",
                                    "proxyGrantingTicket": "pgtIou"
                                    "proxies": [
                                        "http://app/proxyCallback.php"
                                    ]
                                }
                            }
                        }
                        EOF;

                    break;
@@ -185,15 +205,17 @@ class CasHelper

                case 'http://local/cas/proxyValidate?service=http%3A%2F%2Ffrom&ticket=PT-ticket':
                    $body = <<< 'EOF'
                        <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
                         <cas:authenticationSuccess>
                          <cas:user>username</cas:user>
                          <cas:proxyGrantingTicket>pgtIou</cas:proxyGrantingTicket>
                          <cas:proxies>
                            <cas:proxy>http://app/proxyCallback.php</cas:proxy>
                          </cas:proxies>
                         </cas:authenticationSuccess>
                        </cas:serviceResponse>
                        {
                            "serviceResponse": {
                                "authenticationSuccess": {
                                    "user": "username",
                                    "proxyGrantingTicket": "pgtIou",
                                    "proxies": [
                                        "http://app/proxyCallback.php"
                                    ]
                                }
                            }
                        }
                        EOF;

                    break;
@@ -238,7 +260,7 @@ class CasHelper
                            'custom',
                        ],
                        'default_parameters' => [
                            'format' => 'XML',
                            'format' => 'JSON',
                        ],
                    ],
                    'proxyValidate' => [
@@ -249,7 +271,7 @@ class CasHelper
                            'custom',
                        ],
                        'default_parameters' => [
                            'format' => 'XML',
                            'format' => 'JSON',
                        ],
                    ],
                    'proxy' => [
+2 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ class EcasPropertiesSpec extends ObjectBehavior
                                0 => 'userDetails',
                            ],
                            'default_parameters' => [
                                'format' => 'XML',
                                'format' => 'JSON',
                            ],
                        ],
                        'proxyValidate' => [
@@ -40,7 +40,7 @@ class EcasPropertiesSpec extends ObjectBehavior
                                0 => 'userDetails',
                            ],
                            'default_parameters' => [
                                'format' => 'XML',
                                'format' => 'JSON',
                            ],
                        ],
                        'login' => [
+1 −2
Original line number Diff line number Diff line
@@ -29,8 +29,7 @@ class EcasSpec extends ObjectBehavior
{
    public function it_can_do_a_service_ticket_validation_and_make_sure_authenticationLevel_is_correct()
    {
        $from = 'http://local/';
        $request = new ServerRequest('GET', $from);
        $request = new ServerRequest('GET', 'http://local/');

        $this
            ->withServerRequest($request)