Skip to content

Commit

Permalink
Merge pull request #173 from maxmind/greg/fix-user-agent
Browse files Browse the repository at this point in the history
Fix handling of user_agent from array
  • Loading branch information
marselester authored May 2, 2024
2 parents 3ad51f5 + d7e7f55 commit 59a45c6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

3.0.1 (2024-05-02)
------------------

* When calling `withDevice` with an array, an exception was incorrectly
thrown if `user_agent` was set but `session_id` was not set. Reported by
Gregor Kuhlmann. GitHub #172.

3.0.0 (2024-04-16)
------------------

Expand Down
4 changes: 1 addition & 3 deletions src/MinFraud.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@ public function withDevice(
$sessionId = (string) $v;
}
}
if ($sessionId) {
$userAgent = $this->remove($values, 'user_agent');
}
$userAgent = $this->remove($values, 'user_agent');

$this->verifyEmpty($values);
}
Expand Down
11 changes: 11 additions & 0 deletions tests/MaxMind/Test/MinFraudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,17 @@ public function testMissingIpAddressWithoutValidation(string $class, string $ser
);
}

/**
* @dataProvider services
*/
public function testUserAgentWithoutSessionId(string $class, string $service): void
{
$this->createMinFraudRequestWithFullResponse(
$service,
request: ['device' => ['user_agent' => 'test']],
)->withDevice(['user_agent' => 'test'])->{$service}();
}

/**
* @dataProvider withMethods
*/
Expand Down

0 comments on commit 59a45c6

Please sign in to comment.