Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Mock filename tokenizer #3

@Ciloe

Description

@Ciloe

csarrazi/CsaGuzzleBundle#208

Hi, I saw a problem with the fixture file name generated by this function :

src/Cache/NamingStrategy/AbstractNamingStrategy.php

protected function getFingerprint(RequestInterface $request)
    {
        return md5(serialize([
            'method' => $request->getMethod(),
            'path' => $request->getUri()->getPath(),
            'query' => $request->getUri()->getQuery(),
            'user_info' => $request->getUri()->getUserInfo(),
            'port' => $request->getUri()->getPort(),
            'scheme' => $request->getUri()->getScheme(),
            'headers' => array_diff_key($request->getHeaders(), array_flip($this->blacklist)),
        ]));
    }

It's appear that if wee requested a graphQl API, we use the body to send the request and not the query. Is it possible to add 'body' => $request->getBody(), in this array ?

I think a new naming strategy is a good idea. But what can we use in the strategy ? I think this header is the minimum

       [
            'method' => $request->getMethod(),
            'user_info' => $request->getUri()->getUserInfo(),
            'port' => $request->getUri()->getPort(),
            'scheme' => $request->getUri()->getScheme(),
            'headers' => array_diff_key($request->getHeaders(), array_flip($this->blacklist)),
        ]

But, with my tests I can see some problems.

  • If we use the body : 'body' => $request->getBody(). If the request has generic fragments and we change the fragment signature. The naming will change, and we will loose the last name. We need then to delete and regenerate all fixtures...
  • If we use a personal hash in the query : 'query' => $request->getUri()->getQuery() // has a specific hash for exemple, the route who call the api. If they are differents parameters, for a same route, the fixture will be the same.
  • If we use a personal hash in the query with parameters, it will be the same problem if we add a parameter.

What is the good solution for you ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions