mirror of
https://github.com/appwrite/appwrite
synced 2026-05-22 16:38:32 +00:00
Merge branch '1.6.x' of https://github.com/appwrite/appwrite into feat-custom-cf-hostnames
This commit is contained in:
commit
54f39494c0
6 changed files with 62 additions and 8 deletions
|
|
@ -4315,7 +4315,7 @@ App::post('/v1/account/targets/push')
|
|||
|
||||
$device = $detector->getDevice();
|
||||
|
||||
$sessionId = Auth::sessionVerify($user->getAttribute('sessions'), Auth::$secret);
|
||||
$sessionId = Auth::sessionVerify($user->getAttribute('sessions', []), Auth::$secret);
|
||||
$session = $dbForProject->getDocument('sessions', $sessionId);
|
||||
|
||||
try {
|
||||
|
|
@ -4384,7 +4384,9 @@ App::put('/v1/account/targets/:targetId/push')
|
|||
}
|
||||
|
||||
if ($identifier) {
|
||||
$target->setAttribute('identifier', $identifier);
|
||||
$target
|
||||
->setAttribute('identifier', $identifier)
|
||||
->setAttribute('expired', false);
|
||||
}
|
||||
|
||||
$detector = new Detector($request->getUserAgent());
|
||||
|
|
|
|||
|
|
@ -1503,7 +1503,9 @@ App::patch('/v1/users/:userId/targets/:targetId')
|
|||
throw new Exception(Exception::PROVIDER_INCORRECT_TYPE);
|
||||
}
|
||||
|
||||
$target->setAttribute('identifier', $identifier);
|
||||
$target
|
||||
->setAttribute('identifier', $identifier)
|
||||
->setAttribute('expired', false);
|
||||
}
|
||||
|
||||
if ($providerId) {
|
||||
|
|
@ -1517,8 +1519,9 @@ App::patch('/v1/users/:userId/targets/:targetId')
|
|||
throw new Exception(Exception::PROVIDER_INCORRECT_TYPE);
|
||||
}
|
||||
|
||||
$target->setAttribute('providerId', $provider->getId());
|
||||
$target->setAttribute('providerInternalId', $provider->getInternalId());
|
||||
$target
|
||||
->setAttribute('providerId', $provider->getId())
|
||||
->setAttribute('providerInternalId', $provider->getInternalId());
|
||||
}
|
||||
|
||||
if ($name) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Target extends Model
|
|||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Target Name.',
|
||||
'default' => '',
|
||||
'example' => 'Aegon apple token',
|
||||
'example' => 'Apple iPhone 12',
|
||||
])
|
||||
->addRule('userId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
@ -58,6 +58,12 @@ class Target extends Model
|
|||
'description' => 'The target identifier.',
|
||||
'default' => '',
|
||||
'example' => 'token',
|
||||
])
|
||||
->addRule('expired', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Is the target expired.',
|
||||
'default' => false,
|
||||
'example' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2695,4 +2695,45 @@ class AccountCustomClientTest extends Scope
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function testCreatePushTarget(): void
|
||||
{
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/targets/push', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id']
|
||||
], $this->getHeaders()), [
|
||||
'targetId' => ID::unique(),
|
||||
'identifier' => 'test-identifier',
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertEquals('test-identifier', $response['body']['identifier']);
|
||||
}
|
||||
|
||||
public function testUpdatePushTarget(): void
|
||||
{
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/targets/push', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'targetId' => ID::unique(),
|
||||
'identifier' => 'test-identifier-2',
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertEquals('test-identifier-2', $response['body']['identifier']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PUT, '/account/targets/'. $response['body']['$id'] .'/push', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'identifier' => 'test-identifier-updated',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('test-identifier-updated', $response['body']['identifier']);
|
||||
$this->assertEquals(false, $response['body']['expired']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ class HealthCustomServerTest extends Scope
|
|||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('/CN=www.google.com', $response['body']['name']);
|
||||
$this->assertEquals('www.google.com', $response['body']['subjectSN']);
|
||||
$this->assertStringContainsString('Google Trust Services', $response['body']['issuerOrganisation']);
|
||||
$this->assertContains($response['body']['issuerOrganisation'], ['Let\'s Encrypt', 'Google Trust Services']);
|
||||
$this->assertIsInt($response['body']['validFrom']);
|
||||
$this->assertIsInt($response['body']['validTo']);
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ class HealthCustomServerTest extends Scope
|
|||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('/CN=appwrite.io', $response['body']['name']);
|
||||
$this->assertEquals('appwrite.io', $response['body']['subjectSN']);
|
||||
$this->assertEquals("Let's Encrypt", $response['body']['issuerOrganisation']);
|
||||
$this->assertContains($response['body']['issuerOrganisation'], ['Let\'s Encrypt', 'Google Trust Services']);
|
||||
$this->assertIsInt($response['body']['validFrom']);
|
||||
$this->assertIsInt($response['body']['validTo']);
|
||||
|
||||
|
|
|
|||
|
|
@ -1498,6 +1498,7 @@ trait UsersBase
|
|||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('random-email1@mail.org', $response['body']['identifier']);
|
||||
$this->assertEquals(false, $response['body']['expired']);
|
||||
return $response['body'];
|
||||
}
|
||||
|
||||
|
|
@ -1510,6 +1511,7 @@ trait UsersBase
|
|||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals(3, \count($response['body']['targets']));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue