davide.cucurnia@vola.it
2024-02-01 555a537e2e5d9220e3777c30b185606823c817f2
app/Vola/Services/VolaFakeHTTPResponder/VolaFakeHTTPResponder.php
@@ -33,19 +33,24 @@
            } 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"])) {
            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"]["t"] );
            $sampleResponseObject = Utils::convertXMLStrToArray($sampleResponseString);
            $resp = [
@@ -68,7 +73,10 @@
    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"]["t"] );
            $sampleResponseObject = Utils::convertXMLStrToArray($sampleResponseString);
            $resp = [
                'logged' => (string) 1,
@@ -97,27 +105,26 @@
            //verifico se il metodo dell' utente ha la chiave che sto cercando
            if ($key != "t" && 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");
        \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"] ?? [];