| | |
| | | |
| | | } else if ($methodUri != "") { |
| | | // controllo metodo e parametri e conseguente risposta |
| | | $userResponses = $this->getUserResponseSet($request, $testUser); |
| | | $userResponses = $this->getUserResponseSet($testUser, $picasso); |
| | | if (isset($userResponses[$methodUri])) { |
| | | $responseContent = $this->getResponseArgumentsBased($userResponses, $methodUri, $reqParams); |
| | | return $responseContent; |
| | | } else { |
| | | return 'user is not set for this method'; |
| | | } |
| | | } else { |
| | | return 'wront-request-no-such-method'; |
| | | return 'wrong-request-no-such-method'; |
| | | } |
| | | } |
| | | |
| | | public function getLoggedPicasso($testUser) |
| | | { |
| | | if (isset($_COOKIE["SSOSESSIONID"])) { |
| | | $sampleResponseString = Arr::first($this->sso_XML[$testUser]["picasso"]["getWebcustomerInformation"]["parametri"]["t"] ); |
| | | if (!isset($this->sso_XML[$testUser]["picasso"])) { |
| | | return 'this picasso user doesnt exist. check your SSOSESSIONID value'; |
| | | } |
| | | $sampleResponseString = Arr::first($this->sso_XML[$testUser]["picasso"]["getWebcustomerInformation"]["parametri"]["k"] ); |
| | | $sampleResponseObject = Utils::convertXMLStrToArray($sampleResponseString); |
| | | $resp = [ |
| | | 'logged' => (string) 1, |
| | |
| | | public function getLoggedLegacy($testUser) |
| | | { |
| | | if (isset($_COOKIE["CAuthCookie"])) { |
| | | $sampleResponseString = Arr::first($this->sso_XML[$testUser]["picasso"]["getWebcustomerInformation"]["parametri"]["t"] ); |
| | | if (!isset($this->sso_XML[$testUser]["sso"])) { |
| | | return 'this user doesnt exist. check your CAuthCookie value'; |
| | | } |
| | | $sampleResponseString = Arr::first($this->sso_XML[$testUser]["sso"]["getWebcustomerInformation"]["parametri"]["k"] ); |
| | | $sampleResponseObject = Utils::convertXMLStrToArray($sampleResponseString); |
| | | $resp = [ |
| | | 'logged' => (string) 1, |
| | |
| | | //assumo che se la richiesta sia arrivata fin qui abbia tutti i mandatory nel url |
| | | foreach ($reqParams as $key => $value) { |
| | | //verifico se il metodo dell' utente ha la chiave che sto cercando |
| | | if ($key != "t" && isset($params[$key])) { |
| | | if ($key != "k" && isset($params[$key])) { |
| | | if (array_key_exists($value, $params[$key])) { |
| | | \Log::channel('general')->debug("[VolaFakeHTTPResponder] Inserisco xml specifico per key:$key ,params: " . print_r($params, 1) . " key: $key, value: $value, xml: " . print_r($params[$key][$value], 1)); |
| | | \Log::channel('requests')->debug("[VolaFakeHTTPResponder] Inserisco xml specifico per key:$key ,params: " . print_r($params, 1) . " key: $key, value: $value, xml: " . print_r($params[$key][$value], 1)); |
| | | return $params[$key][$value]; |
| | | } |
| | | } |
| | | } |
| | | //xml di default (se richiede parametri di default conterrĂ errori) |
| | | $defaultResponse = Arr::first($params["t"]); |
| | | \Log::channel('general')->debug("[VolaFakeHTTPResponder] Inserisco xml di default $defaultResponse per method: $methodUri"); |
| | | $defaultResponse = Arr::first($params["k"]); |
| | | \Log::channel('requests')->debug("[VolaFakeHTTPResponder] Inserisco xml di default $defaultResponse per method: $methodUri"); |
| | | return $defaultResponse; |
| | | } |
| | | |
| | | /** |
| | | * @param Request $request |
| | | * @param mixed $testUser |
| | | * @param bool $picasso |
| | | * @return array|mixed |
| | | */ |
| | | private function getUserResponseSet(Request $request, mixed $testUser) |
| | | private function getUserResponseSet(mixed $testUser, bool $picasso) |
| | | { |
| | | $url = $request->url(); |
| | | $isPicasso = Str::contains($url, "picasso"); |
| | | if ($isPicasso) { |
| | | if ($picasso) { |
| | | $userMethods = $this->sso_XML[$testUser]["picasso"] ?? []; |
| | | } else { |
| | | $userMethods = $this->sso_XML[$testUser]["sso"] ?? []; |