Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update checks for UrlMatcher #12

Merged
merged 1 commit into from
Mar 18, 2024

Conversation

ollwells
Copy link
Contributor

The UrlMatcher was failing to match when using json POST data

I tweaked the following to check the data

   private function requestBodyDifferent(RequestInterface $request): bool
    {
        if (is_null($this->body)) {
            // Skip if no body provided to check
            return false;
        }

        dump("{$this->body}");
        dump("{$request->getBody()->getContents()}");
        return $this->body !== $request->getBody()->getContents();
    }

and the two lines were the same but the check failed

"{"client_id":"clientID","client_secret":"secret","grant_type":"client_credentials","response_type":"token","scope":"login"}" // vendor/tomb1n0/generic-api-client/src/Matchers/UrlMatcher.php:46
"{"client_id":"clientID","client_secret":"secret","grant_type":"client_credentials","response_type":"token","scope":"login"}" // vendor/tomb1n0/generic-api-client/src/Matchers/UrlMatcher.php:47

I updated to != and the test passed

I think there can be a case where the types are somehow different. We could cast the values but using != seems okay (and we do this in requestMethodDifferent already)

@tomb1n0 tomb1n0 merged commit 926079d into tomb1n0:main Mar 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants