| | |
| | | class VolaFakeHTTPResponder |
| | | { |
| | | public array $data; |
| | | public array $headers; |
| | | private array $xmlResponses; |
| | | |
| | | public function __construct() |
| | |
| | | $this->xmlResponses = config('devtools.fake_sso_profiles'); |
| | | } |
| | | |
| | | public function getModelBasedResponses($request, $selectedUser, $picasso = false): string|array |
| | | public function getModelBasedResponses(Request $request): array |
| | | { |
| | | return 'test. funziono ma le logiche non sono state ancora implementate'; |
| | | $picassoRequest = (str_starts_with($request->getRequestUri(), '/picasso/',)); |
| | | $profile = Utils::getRequestedUser($request); |
| | | |
| | | if (isset($profile)) { |
| | | |
| | | $responseContent["data"] = 'test. funziono ma le logiche non sono state ancora implementate'; |
| | | $responseContent["status"] = 200; |
| | | \RequestLogger::logProcessedRequest($request, $responseContent, (($picassoRequest) ? 'Picasso' : 'SSO Legacy') ); |
| | | return $responseContent; |
| | | |
| | | } else { |
| | | \RequestLogger::logRejectedRequest($request, $request->cookies); |
| | | return [ |
| | | "status" => 400, |
| | | "data" => $this->getErrorMessage('no-cookie') |
| | | ]; |
| | | } |
| | | |
| | | } |
| | | |
| | | public function getResponses(Request $request, $selectedUser, $picasso = false): string|array |
| | |
| | | 'errorCode' => (string) 0, |
| | | 'username' => (string) $sampleResponseObject["Username"], |
| | | 'next_user' => (string) 'N', |
| | | //'token' => '415F2B31F1C15FA45C9A6E1CBEB0ADF3' |
| | | 'token' => '415F2B31F1C15FA45C9A6E1CBEB0ADF3' |
| | | ]; |
| | | } else { |
| | | $resp = [ |
| | |
| | | 'logged' => (string) 1, |
| | | 'errorCode' => (string) 0, |
| | | 'username' => (string) $sampleResponseObject["Username"], |
| | | 'token' => (string) '415F2B31F1C15FA45C9A6E1CBEB0ADF3', |
| | | 'token' => (string) 'xno:' . $selectedUser, |
| | | 'next_user' => (string) 'N', |
| | | ]; |
| | | } else { |
| | |
| | | private function getErrorMessage(string $code): string |
| | | { |
| | | switch ($code) { |
| | | case 'no-cookie': |
| | | return 'No cookie No Party. Send your CAuthCookie or SESSIONID cookie'; |
| | | case 'no-sso-user': |
| | | return 'this sso user doesnt exist. check your CAuthCookie value'; |
| | | return 'This sso user doesnt exist. Check your CAuthCookie cookie value'; |
| | | case 'no-picasso-user': |
| | | return 'this picasso user doesnt exist. check your SSOSESSIONID value'; |
| | | return 'This picasso user doesnt exist. Check your SSOSESSIONID coookie value'; |
| | | case 'no-method-on-user': |
| | | return 'this method response is not set for this user'; |
| | | return 'This method response is not set for this user. Check this server database.'; |
| | | case 'no-method': |
| | | return 'couldnt detect requested method'; |
| | | return 'Couldnt detect requested method. Check your request url.'; |
| | | default: |
| | | return 'couldnt detect proper response. check your syntax'; |
| | | return 'Couldnt detect proper response.'; |
| | | } |
| | | } |
| | | |