Skip to content

Commit 16d1475

Browse files
committed
EXTERNAL_LOG_TOKEN replaced by API_KEY user-token
1 parent 7f55f9c commit 16d1475

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/Manager/LogManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function externalLog(string $value): void
4242

4343
// make request to admin-suite log api
4444
$this->jsonUtil->getJson(
45-
target: $externalLogUrl . '?name=' . urlencode('code-paste: log') . '&message=' . urlencode('code-paste: ' . $value) . '&level=4',
45+
target: $externalLogUrl . '?name=' . rawurlencode('code-paste: log') . '&message=' . rawurlencode('code-paste: ' . $value) . '&level=4',
4646
apiKey: $externalLogToken,
4747
method: 'POST'
4848
);

tests/Manager/LogManagerTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,18 @@ public function testSendLogMessageToExternalLogApiWhenExternalLogEnabled(): void
6868
// log message
6969
$value = 'This is a test log message';
7070

71+
// expect env values to be fetched for url and api key
72+
$this->appUtilMock->expects($this->exactly(2))->method('getEnvValue')->willReturnMap([
73+
['EXTERNAL_LOG_URL', 'https://external-log-service.com/log'],
74+
['EXTERNAL_LOG_API_TOKEN', 'test-token']
75+
]);
76+
7177
// expect json util get json call
72-
$this->jsonUtilMock->expects($this->once())->method('getJson');
78+
$this->jsonUtilMock->expects($this->once())->method('getJson')->with(
79+
$this->equalTo('https://external-log-service.com/log?name=code-paste%3A%20log&message=code-paste%3A%20This%20is%20a%20test%20log%20message&level=4'),
80+
$this->equalTo('POST'),
81+
$this->equalTo('test-token')
82+
);
7383

7484
// call tested method
7585
$this->logManager->externalLog($value);

0 commit comments

Comments
 (0)