Re-enable AccountVerifyCredentials test

This commit is contained in:
Philipp 2021-12-04 22:34:51 +01:00
parent 902bcc506f
commit cc7b2fae4e
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
4 changed files with 246 additions and 174 deletions

View File

@ -52,6 +52,6 @@ class VerifyCredentials extends BaseApi
// @todo Support the source property, // @todo Support the source property,
$account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid); $account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid);
System::jsonExit($account); $this->response->exit('account', ['account' => $account->toArray()]);
} }
} }

View File

@ -220,6 +220,55 @@ return [
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'location' => 'DFRN', 'location' => 'DFRN',
], ],
[
'id' => 42,
'uid' => 0,
'uri-id' => 42,
'name' => 'Self contact',
'nick' => 'selfcontact',
'self' => 1,
'nurl' => 'http://localhost/profile/selfcontact',
'url' => 'http://localhost/profile/selfcontact',
'about' => 'User used in tests',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::FOLLOWER,
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
],
'apcontact' => [
[
"url" => "http://localhost/profile/selfcontact",
"uri-id" => 1,
"uuid" => "42",
"type" => "Person",
"following" => "http://localhost/following/selfcontact",
"followers" => "http://localhost/followers/selfcontact",
"inbox" => "http://localhost/inbox/selfcontact",
"outbox" => "http://localhost/outbox/selfcontact",
"sharedinbox" => "http://localhost/inbox",
"manually-approve" => 1,
"discoverable" => 0,
"nick" => "selfcontact",
"name" => "Self contact",
"about" => "User used in tests",
"xmpp" => null,
"matrix" => null,
"photo" => "http://localhost/photo/profile/admin.jpeg",
"header" => null,
"addr" => "selfcontact@localhost",
"alias" => null,
"pubkey" => "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzLquDFnFxNYZZFQNbA9f\nkgtUJpC+MPrhxhEsjxme1ivvE4itdPnCueBHifknUkwfmqormyeqr4TdoVbNuKRg\nj2QRBdtaGbUJLQVdbiTKFOmJIYMtV05WIIHEhUW84fwIXmF+6u3kbOw+sIjWY3OW\nwC/2+54HiYS2n8cddfwoZBim6Na8yyQI8pQSKqJ+I4gDfkGuoVex0svNPEv9liLE\nykpQ3PuoeLJV2Wex0Cy6FYPgcfH6xvvUVxh6e8w0w22jC3DJInfDrmbw5H7aUbf+\nMMwV3TVI6/CqTO0cLEOZUjsUwdm6lIV0O0fTsrkjU9G0bc0sLJl7n9i9ICDOKOMf\nCLaK2Pj2sVbpkzXJoufLUDf0oSftdVvN9jR9WYxRdnwsyF8N/xVTw8AsyHhkXawR\n3YDgi6i2uZj5kvG7GPBf7EPZ/MpbGhEZB+/GQuZuyhLdgFDSi/uX8STBmn1jI/zY\nTLZ8JCwMzFKAXAtYaBPklZBbcRyz9O1893MsAXO8d6ODTOkD324gAjRUtuOMscYc\nWV98NZIUSbqQrznmMoJn1fiMNVgx+UXOPkiZuDxnrr1T3vynKnl5LXmadx2YeoAf\nxPeCoDb0eJtCDLcsTZ9qlztaEaohPV+H3HBSpdItea7LgAbccILHPssk9tUgmHVl\na5yV8uFenhKKQ9g93Pt63LsCAwEAAQ==\n-----END PUBLIC KEY-----",
"subscribe" => "/follow?url={uri}",
"baseurl" => null,
"gsid" => null,
"generator" => "Friendica 'Siberian Iris' 2021.12-dev-1443",
"following_count" => 0,
"followers_count" => 0,
"statuses_count" => 0,
"updated" => "2021-11-19 19:17:59",
],
], ],
'verb' => [ 'verb' => [
[ [

View File

@ -2,6 +2,9 @@
namespace Friendica\Test\src\Module\Api\Mastodon\Accounts; namespace Friendica\Test\src\Module\Api\Mastodon\Accounts;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Mastodon\Accounts\Statuses;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class StatusesTest extends ApiTest class StatusesTest extends ApiTest
@ -11,6 +14,8 @@ class StatusesTest extends ApiTest
*/ */
public function testApiStatusShowWithJson() public function testApiStatusShowWithJson()
{ {
self::markTestIncomplete('Needs Stastuses to not set header during call (like at BaseApi::setLinkHeader');
// $result = api_status_show('json', 1); // $result = api_status_show('json', 1);
// self::assertStatus($result['status']); // self::assertStatus($result['status']);
} }
@ -20,6 +25,8 @@ class StatusesTest extends ApiTest
*/ */
public function testApiStatusShowWithXml() public function testApiStatusShowWithXml()
{ {
self::markTestIncomplete('Needs Stastuses to not set header during call (like at BaseApi::setLinkHeader');
// $result = api_status_show('xml', 1); // $result = api_status_show('xml', 1);
// self::assertXml($result, 'statuses'); // self::assertXml($result, 'statuses');
} }

View File

@ -2,6 +2,9 @@
namespace Friendica\Test\src\Module\Api\Mastodon\Accounts; namespace Friendica\Test\src\Module\Api\Mastodon\Accounts;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Mastodon\Accounts\VerifyCredentials;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class VerifyCredentialsTest extends ApiTest class VerifyCredentialsTest extends ApiTest
@ -13,7 +16,18 @@ class VerifyCredentialsTest extends ApiTest
*/ */
public function testApiAccountVerifyCredentials() public function testApiAccountVerifyCredentials()
{ {
// self::assertArrayHasKey('user', api_account_verify_credentials('json')); $verifyCredentials = new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
$response = $verifyCredentials->run();
$body = (string)$response->getBody();
self::assertJson($body);
$json = json_decode($body);
self::assertEquals(42, $json->id);
self::assertIsArray($json->emojis);
self::assertIsArray($json->fields);
} }
/** /**
@ -23,6 +37,8 @@ class VerifyCredentialsTest extends ApiTest
*/ */
public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser() public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
{ {
self::markTestIncomplete('Needs dynamic BasicAuth first');
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
// BasicAuth::setCurrentUserID(); // BasicAuth::setCurrentUserID();
// $_SESSION['authenticated'] = false; // $_SESSION['authenticated'] = false;