diff --git a/composer.json b/composer.json
index 104494ef..e9125efe 100644
--- a/composer.json
+++ b/composer.json
@@ -36,7 +36,8 @@
"test": "SHELL_INTERACTIVE=1 vendor/bin/phpunit --colors=always --verbose ",
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml",
"phpcs": "SHELL_INTERACTIVE=1 ./vendor/bin/phpcs --standard=phpcs-ruleset.xml -s",
- "phpcbf": "SHELL_INTERACTIVE=1 ./vendor/bin/phpcbf --standard=phpcs-ruleset.xml .",
+ "phpcbf": "./vendor/bin/phpcbf --standard=phpcs-ruleset.xml .",
+ "phpcbf-path": "SHELL_INTERACTIVE=1 ./vendor/bin/phpcbf --standard=phpcs-ruleset.xml",
"sniffs": "./vendor/bin/phpcs --standard=phpcs-ruleset.xml -e"
}
}
diff --git a/phpcs-ruleset.xml b/phpcs-ruleset.xml
index 9becbb9a..63f17085 100644
--- a/phpcs-ruleset.xml
+++ b/phpcs-ruleset.xml
@@ -26,6 +26,12 @@
+
+
+
+
+
+
@@ -51,6 +57,7 @@
+
@@ -61,7 +68,7 @@
-
+
@@ -78,9 +85,9 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/API/Management/Logs.php b/src/API/Management/Logs.php
index a0b106d3..d34cdadd 100644
--- a/src/API/Management/Logs.php
+++ b/src/API/Management/Logs.php
@@ -2,34 +2,52 @@
namespace Auth0\SDK\API\Management;
+/**
+ * Class Logs.
+ * Access to the v2 Management API Logs endpoint.
+ *
+ * @package Auth0\SDK\API\Management
+ */
class Logs extends GenericResource
{
/**
+ * Get a single Log event.
+ * Required scope: "read:logs"
+ *
+ * @param string $log_id Log entry ID to get.
*
- * @param string $id
* @return mixed
+ *
+ * @throws \Exception Thrown by Guzzle for API errors.
+ *
+ * @link https://auth0.com/docs/api/management/v2#!/Logs/get_logs_by_id
*/
- public function get($id)
+ public function get($log_id)
{
- return $this->apiClient->get()
- ->logs($id)
- ->call();
+ return $this->apiClient->method('get')
+ ->addPath('logs', $log_id)
+ ->call();
}
/**
+ * Retrieves log entries that match the specified search criteria (or list all entries if no criteria is used).
+ * Required scope: "read:logs"
+ *
+ * @param array $params Log search parameters to send:
+ * - Including a restricted "fields" parameter can speed up API calls significantly.
+ * - Results are paged by default; pass a "page" and "per_page" param to adjust what results are shown.
*
- * @param array $params
* @return mixed
+ *
+ * @throws \Exception Thrown by Guzzle for API errors.
+ *
+ * @link https://auth0.com/docs/api/management/v2#!/Logs/get_logs
*/
- public function search($params = [])
+ public function search(array $params = [])
{
- $client = $this->apiClient->get()
- ->logs();
-
- foreach ($params as $param => $value) {
- $client->withParam($param, $value);
- }
-
- return $client->call();
+ return $this->apiClient->method('get')
+ ->addPath('logs')
+ ->withDictParams($params)
+ ->call();
}
}
diff --git a/tests/API/Management/LogsTest.php b/tests/API/Management/LogsTest.php
new file mode 100644
index 00000000..d5aa5a72
--- /dev/null
+++ b/tests/API/Management/LogsTest.php
@@ -0,0 +1,87 @@
+ [ 'actions' => ['read'] ] ]);
+ $api = new Management($token, $env['DOMAIN'], ['timeout' => 30]);
+
+ self::$api = $api->logs;
+ }
+
+ /**
+ * Test a general search.
+ *
+ * @return void
+ */
+ public function testLogSearchAndGetById()
+ {
+ $search_results = self::$api->search([
+ 'fields' => '_id,log_id,date',
+ 'include_fields' => true,
+ ]);
+ $this->assertNotEmpty($search_results);
+ $this->assertNotEmpty($search_results[0]['_id']);
+ $this->assertNotEmpty($search_results[0]['log_id']);
+ $this->assertNotEmpty($search_results[0]['date']);
+ $this->assertCount(3, $search_results[0]);
+
+ // Test getting a single log result with a valid ID from above.
+ $one_log = self::$api->get($search_results[0]['log_id']);
+ $this->assertNotEmpty($one_log);
+ $this->assertEquals($search_results[0]['log_id'], $one_log['log_id']);
+ }
+
+ /**
+ * Test pagination parameters.
+ *
+ * @return void
+ */
+ public function testLogSearchPagination()
+ {
+ $expected_count = 5;
+ $search_results= self::$api->search([
+ // Fields here to speed up API call.
+ 'fields' => '_id,log_id',
+ 'include_fields' => true,
+
+ // Second page of 5 results.
+ 'page' => 1,
+ 'per_page' => $expected_count,
+
+ // Include totals to check pagination.
+ 'include_totals' => true,
+ ]);
+
+ $this->assertCount($expected_count, $search_results['logs']);
+ $this->assertEquals($expected_count, $search_results['length']);
+
+ // Starting on 2nd page so starting result should be equal to the number per page.
+ $this->assertEquals($expected_count, $search_results['start']);
+ }
+}
diff --git a/tests/API/Management/UsersTest.php b/tests/API/Management/UsersTest.php
index 3089cafb..cee5c2e3 100644
--- a/tests/API/Management/UsersTest.php
+++ b/tests/API/Management/UsersTest.php
@@ -57,7 +57,7 @@ protected function getCreateBody()
'email' => 'test-create-user-'.$this->rand.'@auth0.com',
'password' => 'Y6t82hQjpXCMd3oD7Zsc',
'picture' => 'https://cdn.auth0.com/styleguide/components/1.0.8/media/logos/img/badge.png',
- 'email_verified' => false,
+ 'email_verified' => true,
'user_metadata' => [
'key1' => 'value1',
'key2' => 'value2',
@@ -116,7 +116,7 @@ protected function afterCreate($entity)
$expected = $this->getCreateBody();
$this->assertNotEmpty($this->getId($entity));
$this->assertEquals($expected['email'], $entity['email']);
- $this->assertFalse($entity['email_verified']);
+ $this->assertTrue($entity['email_verified']);
$this->assertEquals($expected['user_metadata']['key1'], $entity['user_metadata']['key1']);
$this->assertEquals($expected['user_metadata']['key2'], $entity['user_metadata']['key2']);
}
@@ -130,7 +130,7 @@ protected function getUpdateBody()
{
return [
'email' => 'test-update-user-'.$this->rand.'@auth0.com',
- 'email_verified' => true,
+ 'email_verified' => false,
'user_metadata' => [
'key1' => 'value4',
'key3' => 'value3',
@@ -147,7 +147,7 @@ protected function afterUpdate($entity)
{
$expected = $this->getUpdateBody();
$this->assertEquals($expected['email'], $entity['email']);
- $this->assertTrue($entity['email_verified']);
+ $this->assertFalse($entity['email_verified']);
$this->assertEquals($expected['user_metadata']['key1'], $entity['user_metadata']['key1']);
$this->assertEquals($expected['user_metadata']['key3'], $entity['user_metadata']['key3']);
}