diff --git a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Create.php b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Create.php index c1f164987f..a00f3f146d 100644 --- a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Create.php +++ b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Create.php @@ -39,7 +39,7 @@ class Create extends Action ->label('sdk.response.model', Response::MODEL_KEY) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') - ->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.', true) + ->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.', false) ->inject('response') ->inject('dbForConsole') ->callback(fn ($projectId, $name, $expire, $response, $dbForConsole) => $this->action($projectId, $name, $expire, $response, $dbForConsole)); diff --git a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Update.php b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Update.php index fd09bdead8..9379c147f2 100644 --- a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Update.php +++ b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Update.php @@ -36,7 +36,7 @@ class Update extends Action ->param('projectId', '', new UID(), 'Project unique ID.') ->param('keyId', '', new UID(), 'Key unique ID.') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') - ->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.', true) + ->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.', true) ->inject('response') ->inject('dbForConsole') ->callback(fn ($projectId, $keyId, $name, $expire, $response, $dbForConsole) => $this->action($projectId, $keyId, $name, $expire, $response, $dbForConsole)); @@ -61,7 +61,7 @@ class Update extends Action $key ->setAttribute('name', $name) - ->setAttribute('expire', $expire); + ->setAttribute('expire', $expire ?? $key->getAttribute('expire')); $dbForConsole->updateDocument('developmentKeys', $key->getId(), $key); diff --git a/tests/e2e/Services/Projects/ProjectsDevelopmentKeys.php b/tests/e2e/Services/Projects/ProjectsDevelopmentKeys.php index de9f4db3fd..15ccfa0949 100644 --- a/tests/e2e/Services/Projects/ProjectsDevelopmentKeys.php +++ b/tests/e2e/Services/Projects/ProjectsDevelopmentKeys.php @@ -19,7 +19,8 @@ trait ProjectsDevelopmentKeys 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'name' => 'Key Test' + 'name' => 'Key Test', + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -31,6 +32,16 @@ trait ProjectsDevelopmentKeys $this->assertArrayHasKey('accessedAt', $response['body']); $this->assertEmpty($response['body']['accessedAt']); + /** TEST expiry date is required */ + $res = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/development-keys', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'name' => 'Key Test' + ]); + + $this->assertEquals(400, $res['headers']['status-code']); + $data = array_merge($data, [ 'keyId' => $response['body']['$id'], 'secret' => $response['body']['secret'] @@ -133,7 +144,7 @@ trait ProjectsDevelopmentKeys 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'name' => 'Key Test', - 'expire' => null, + 'expire' => DateTime::addSeconds(new \DateTime(), 3600), ]); $response = $this->client->call(Client::METHOD_GET, '/health', [