From 9fe427a9c5b45071cc4ee1f0da97c6ca11ad32e1 Mon Sep 17 00:00:00 2001 From: Sebastian Lemke Date: Sun, 20 Apr 2025 23:30:33 +0200 Subject: [PATCH] added DeviceCode Grant --- src/Grant/DeviceCode.php | 35 +++++++++++++++++++++++++++ test/src/Grant/DeviceCodeTest.php | 39 +++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/Grant/DeviceCode.php create mode 100644 test/src/Grant/DeviceCodeTest.php diff --git a/src/Grant/DeviceCode.php b/src/Grant/DeviceCode.php new file mode 100644 index 00000000..b6dd4ec2 --- /dev/null +++ b/src/Grant/DeviceCode.php @@ -0,0 +1,35 @@ + 'mock_device_code']], + ]; + } + + protected function getParamExpectation() + { + return function ($body) { + return !empty($body['grant_type']) + && $body['grant_type'] === 'urn:ietf:params:oauth:grant-type:device_code' + && !empty($body['device_code']); + }; + } + + public function testToString() + { + $grant = new DeviceCode(); + $this->assertEquals('urn:ietf:params:oauth:grant-type:device_code', (string) $grant); + } + + public function testInvalidDeviceCode() + { + $this->expectException(BadMethodCallException::class); + + $this->getMockProvider()->getAccessToken('device_code', ['invalid_device_code' => 'mock_device_code']); + } + +}