Reenable Twitter/Create&Destory tests

This commit is contained in:
Philipp 2021-12-09 22:30:35 +01:00
parent 204b8b6e49
commit d9949610c5
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
4 changed files with 137 additions and 96 deletions

View file

@ -69,7 +69,8 @@ return [
'username' => 'Test user',
'nickname' => 'selfcontact',
'verified' => 1,
'password' => '$2y$10$DLRNTRmJgKe1cSrFJ5Jb0edCqvXlA9sh/RHdSnfxjbR.04yZRm4Qm',
'prvkey' => "-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQDVqxF9kIgtgRL0+q+jTi578FA1r1+crEmlYc0pdxcbmmrhjuRc\nrK1gX3r0mnP25fkHzG+6CAjgbDBRFM1/RXBCyp/KHVks7eQ4yr4MxTRlsxo5qf2o\nnbyNzM7Q+LZhFhe/yIoGN/fuEjlqBE98IfPOrUjsQPX240vGNXIkfLiAWwIDAQAB\nAoGBAIwuiPIdggqAtWQ+mD8HCx5LQwSFw6/xpPu5F7ZNqL52aAsGCbL3o2QoIG4c\na1qf9Ot16BNgNBqxQF3hzRTkBMrKYlmNTUkwJXun/zjQJq2JvOlcrSuXlIucUjs4\nXekVN25aYPHrX9m2FEIUwZTb4UYXbR80KbIDI53BkQ6EwSbpAkEA7aO49CR2Hf1Y\n1d2GaUI/Z0wvbj//+t0Kg0bPt16ca8KVjEQQA5ylsDaiw510jDz9NBQxSOk6If23\nUeRixc1RDQJBAOYtN4YnPM1Zfp6IxXlqMCc+xUWRTPEPFt+WpG+v79koNamAeA6o\nZzTl92hl58IqSdbgojeE2zXWQRvlimFMLQcCQQCV6jND0byyLqFcSeQBg0l8YROK\n+dUC7W80YfeoNod3c8nkMwvnO2tLPyxvO2XLEq6prBNra7bAus5rWyj0oBIBAkEA\n1EvUMFm0TLpEfLgtWuTD8Q6GKLnxO0ztjd+FXrXpBGN/ywyArxRHzJRmctW6wmz6\nmcOqGobhIHCysKYv0bnOtQJAc2M5RwlASHH4jGJzXgt3nboyiJfufM0RV9iry3ho\nCXQRWAONKoLqnsfC6qNP8OzY8FMJcwmPWj7Q/6z6yLBFTA==\n-----END RSA PRIVATE KEY-----",
'pubkey' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVqxF9kIgtgRL0+q+jTi578FA1\nr1+crEmlYc0pdxcbmmrhjuRcrK1gX3r0mnP25fkHzG+6CAjgbDBRFM1/RXBCyp/K\nHVks7eQ4yr4MxTRlsxo5qf2onbyNzM7Q+LZhFhe/yIoGN/fuEjlqBE98IfPOrUjs\nQPX240vGNXIkfLiAWwIDAQAB\n-----END PUBLIC KEY-----", 'password' => '$2y$10$DLRNTRmJgKe1cSrFJ5Jb0edCqvXlA9sh/RHdSnfxjbR.04yZRm4Qm',
'theme' => 'frio',
],
],
@ -137,6 +138,8 @@ return [
'nurl' => 'http://localhost/profile/selfcontact',
'url' => 'http://localhost/profile/selfcontact',
'about' => 'User used in tests',
'prvkey' => "-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQDVqxF9kIgtgRL0+q+jTi578FA1r1+crEmlYc0pdxcbmmrhjuRc\nrK1gX3r0mnP25fkHzG+6CAjgbDBRFM1/RXBCyp/KHVks7eQ4yr4MxTRlsxo5qf2o\nnbyNzM7Q+LZhFhe/yIoGN/fuEjlqBE98IfPOrUjsQPX240vGNXIkfLiAWwIDAQAB\nAoGBAIwuiPIdggqAtWQ+mD8HCx5LQwSFw6/xpPu5F7ZNqL52aAsGCbL3o2QoIG4c\na1qf9Ot16BNgNBqxQF3hzRTkBMrKYlmNTUkwJXun/zjQJq2JvOlcrSuXlIucUjs4\nXekVN25aYPHrX9m2FEIUwZTb4UYXbR80KbIDI53BkQ6EwSbpAkEA7aO49CR2Hf1Y\n1d2GaUI/Z0wvbj//+t0Kg0bPt16ca8KVjEQQA5ylsDaiw510jDz9NBQxSOk6If23\nUeRixc1RDQJBAOYtN4YnPM1Zfp6IxXlqMCc+xUWRTPEPFt+WpG+v79koNamAeA6o\nZzTl92hl58IqSdbgojeE2zXWQRvlimFMLQcCQQCV6jND0byyLqFcSeQBg0l8YROK\n+dUC7W80YfeoNod3c8nkMwvnO2tLPyxvO2XLEq6prBNra7bAus5rWyj0oBIBAkEA\n1EvUMFm0TLpEfLgtWuTD8Q6GKLnxO0ztjd+FXrXpBGN/ywyArxRHzJRmctW6wmz6\nmcOqGobhIHCysKYv0bnOtQJAc2M5RwlASHH4jGJzXgt3nboyiJfufM0RV9iry3ho\nCXQRWAONKoLqnsfC6qNP8OzY8FMJcwmPWj7Q/6z6yLBFTA==\n-----END RSA PRIVATE KEY-----",
'pubkey' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVqxF9kIgtgRL0+q+jTi578FA1\nr1+crEmlYc0pdxcbmmrhjuRcrK1gX3r0mnP25fkHzG+6CAjgbDBRFM1/RXBCyp/K\nHVks7eQ4yr4MxTRlsxo5qf2onbyNzM7Q+LZhFhe/yIoGN/fuEjlqBE98IfPOrUjs\nQPX240vGNXIkfLiAWwIDAQAB\n-----END PUBLIC KEY-----",
'pending' => 0,
'blocked' => 0,
'rel' => Contact::FOLLOWER,
@ -259,7 +262,7 @@ return [
"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-----",
"pubkey" => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVqxF9kIgtgRL0+q+jTi578FA1\nr1+crEmlYc0pdxcbmmrhjuRcrK1gX3r0mnP25fkHzG+6CAjgbDBRFM1/RXBCyp/K\nHVks7eQ4yr4MxTRlsxo5qf2onbyNzM7Q+LZhFhe/yIoGN/fuEjlqBE98IfPOrUjs\nQPX240vGNXIkfLiAWwIDAQAB\n-----END PUBLIC KEY-----",
"subscribe" => "/follow?url={uri}",
"baseurl" => null,
"gsid" => null,

View file

@ -876,100 +876,6 @@ class ApiTest extends FixtureTest
// self::assertStatus($result['status']);
}
/**
* Test the api_favorites_create_destroy() function.
*
* @return void
*/
public function testApiFavoritesCreateDestroy()
{
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
// DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
// api_favorites_create_destroy('json');
}
/**
* Test the api_favorites_create_destroy() function with an invalid ID.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithInvalidId()
{
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
// DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
// api_favorites_create_destroy('json');
}
/**
* Test the api_favorites_create_destroy() function with an invalid action.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithInvalidAction()
{
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
// DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
// $_REQUEST['id'] = 1;
// api_favorites_create_destroy('json');
}
/**
* Test the api_favorites_create_destroy() function with the create action.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithCreateAction()
{
// DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
// $_REQUEST['id'] = 3;
// $result = api_favorites_create_destroy('json');
// self::assertStatus($result['status']);
}
/**
* Test the api_favorites_create_destroy() function with the create action and an RSS result.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
{
// DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
// $_REQUEST['id'] = 3;
// $result = api_favorites_create_destroy('rss');
// self::assertXml($result, 'status');
}
/**
* Test the api_favorites_create_destroy() function with the destroy action.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithDestroyAction()
{
// DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
// $_REQUEST['id'] = 3;
// $result = api_favorites_create_destroy('json');
// self::assertStatus($result['status']);
}
/**
* Test the api_favorites_create_destroy() function without an authenticated user.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
{
/*
$this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
BasicAuth::setCurrentUserID();
$_SESSION['authenticated'] = false;
api_favorites_create_destroy('json');
*/
}
/**
* Test the api_format_messages() function.
*

View file

@ -0,0 +1,74 @@
<?php
namespace Friendica\Test\src\Module\Api\Twitter\Favorites;
use Friendica\App\Router;
use Friendica\Capabilities\ICanCreateResponses;
use Friendica\DI;
use Friendica\Module\Api\Twitter\Favorites\Create;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Test\src\Module\Api\ApiTest;
class CreateTest extends ApiTest
{
/**
* Test the api_favorites_create_destroy() function with an invalid ID.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithInvalidId()
{
$this->expectException(BadRequestException::class);
$create = new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
$create->run();
}
/**
* Test the api_favorites_create_destroy() function with the create action.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithCreateAction()
{
$create = new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
$response = $create->run(['id' => 3]);
$json = $this->toJson($response);
self::assertStatus($json);
}
/**
* Test the api_favorites_create_destroy() function with the create action and an RSS result.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
{
$create = new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => ICanCreateResponses::TYPE_RSS]);
$response = $create->run(['id' => 3]);
self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
self::assertXml((string)$response->getBody(), 'statuses');
}
/**
* Test the api_favorites_create_destroy() function without an authenticated user.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
{
self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
/*
$this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
BasicAuth::setCurrentUserID();
$_SESSION['authenticated'] = false;
api_favorites_create_destroy('json');
*/
}
}

View file

@ -0,0 +1,58 @@
<?php
namespace Friendica\Test\src\Module\Api\Twitter\Favorites;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Twitter\Favorites\Destroy;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Test\src\Module\Api\ApiTest;
class DestroyTest extends ApiTest
{
/**
* Test the api_favorites_create_destroy() function with an invalid ID.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithInvalidId()
{
$this->expectException(BadRequestException::class);
$destroy = new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
$destroy->run();
}
/**
* Test the api_favorites_create_destroy() function with the destroy action.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithDestroyAction()
{
$destroy = new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
$response = $destroy->run(['id' => 3]);
$json = $this->toJson($response);
self::assertStatus($json);
}
/**
* Test the api_favorites_create_destroy() function without an authenticated user.
*
* @return void
*/
public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
{
self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
/*
$this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
BasicAuth::setCurrentUserID();
$_SESSION['authenticated'] = false;
api_favorites_create_destroy('json');
*/
}
}