Normalize local node hostname across API fixtures

- This was causing the fixture data to be wrongly "repaired" in Model\User::getOwnerDataById because of a mismatch between the local base URL and the fixture-provided self contact URL
This commit is contained in:
Hypolite Petovan 2024-02-24 23:46:54 -05:00
parent d37699bc08
commit ba0a8069c4
4 changed files with 46 additions and 55 deletions

View File

@ -35,7 +35,7 @@ trait DatabaseTestTrait
// Rollbacks every DB usage (in case the test couldn't call tearDown) // Rollbacks every DB usage (in case the test couldn't call tearDown)
StaticDatabase::statRollback(); StaticDatabase::statRollback();
// Rollback the first, outer transaction just 2 be sure // Rollback the first, outer transaction just 2 be sure
StaticDatabase::getGlobConnection()->rollBack(); StaticDatabase::getGlobConnection()->rollback();
// Start the first, outer transaction // Start the first, outer transaction
StaticDatabase::getGlobConnection()->beginTransaction(); StaticDatabase::getGlobConnection()->beginTransaction();
} }

View File

@ -211,7 +211,7 @@ class StaticDatabase extends Database
{ {
if (isset(self::$staticConnection)) { if (isset(self::$staticConnection)) {
while (self::$staticConnection->getTransactionDepth() > 0) { while (self::$staticConnection->getTransactionDepth() > 0) {
self::$staticConnection->rollBack(); self::$staticConnection->rollback();
} }
} }
} }

View File

@ -25,16 +25,6 @@ use Friendica\Model\Item;
use Friendica\Model\Notification; use Friendica\Model\Notification;
return [ return [
// Empty these tables
'profile_field',
'permissionset',
'cache',
'conversation',
'pconfig',
'photo',
'workerqueue',
'mail',
'post-delivery-data',
'gserver' => [ 'gserver' => [
[ [
'url' => 'https://friendica.local', 'url' => 'https://friendica.local',
@ -94,22 +84,22 @@ return [
], ],
[ [
'id' => 42, 'id' => 42,
'uri' => 'http://localhost/profile/selfcontact', 'uri' => 'https://friendica.local/profile/selfcontact',
'guid' => '42', 'guid' => '42',
], ],
[ [
'id' => 43, 'id' => 43,
'uri' => 'http://localhost/profile/othercontact', 'uri' => 'https://friendica.local/profile/othercontact',
'guid' => '43', 'guid' => '43',
], ],
[ [
'id' => 44, 'id' => 44,
'uri' => 'http://localhost/profile/friendcontact', 'uri' => 'https://friendica.local/profile/friendcontact',
'guid' => '44', 'guid' => '44',
], ],
[ [
'id' => 46, 'id' => 46,
'uri' => 'http://localhost/profile/mutualcontact', 'uri' => 'https://friendica.local/profile/mutualcontact',
'guid' => '46', 'guid' => '46',
], ],
[ [
@ -126,9 +116,9 @@ return [
'name' => 'Self contact', 'name' => 'Self contact',
'nick' => 'selfcontact', 'nick' => 'selfcontact',
'self' => 1, 'self' => 1,
'nurl' => 'http://localhost/profile/selfcontact', 'nurl' => 'http://friendica.local/profile/selfcontact',
'url' => 'http://localhost/profile/selfcontact', 'url' => 'https://friendica.local/profile/selfcontact',
'notify' => 'http://localhost/friendica/inbox', 'notify' => 'https://friendica.local/friendica/inbox',
'about' => 'User used in tests', '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+dUC7W80YfeoNod3c8nkMwvnO2tLPyxvO2XLEq6prB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FMJcwmPWj7Q/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-----", 'pubkey' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVqxF9kIgtgRL0+q+jTi578FA1\nr1+crEmlYc0pdxcbmmrhjuRcrK1gX3r0mnP25fkHzG+6CAjgbDBRFM1/RXBCyp/K\nHVks7eQ4yr4MxTRlsxo5qf2onbyNzM7Q+LZhFhe/yIoGN/fuEjlqBE98IfPOrUjs\nQPX240vGNXIkfLiAWwIDAQAB\n-----END PUBLIC KEY-----",
@ -137,6 +127,7 @@ return [
'rel' => Contact::FOLLOWER, 'rel' => Contact::FOLLOWER,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'location' => 'DFRN', 'location' => 'DFRN',
'baseurl' => 'https://friendica.local',
], ],
// Having the same name and nick allows us to test // Having the same name and nick allows us to test
// the fallback to api_get_nick() in api_get_user() // the fallback to api_get_nick() in api_get_user()
@ -147,9 +138,9 @@ return [
'name' => 'othercontact', 'name' => 'othercontact',
'nick' => 'othercontact', 'nick' => 'othercontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/othercontact', 'nurl' => 'http://friendica.local/profile/othercontact',
'url' => 'http://localhost/profile/othercontact', 'url' => 'https://friendica.local/profile/othercontact',
'notify' => 'http://localhost/friendica/inbox', 'notify' => 'https://friendica.local/friendica/inbox',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::NOTHING, 'rel' => Contact::NOTHING,
@ -163,9 +154,9 @@ return [
'name' => 'Friend contact', 'name' => 'Friend contact',
'nick' => 'friendcontact', 'nick' => 'friendcontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/friendcontact', 'nurl' => 'http://friendica.local/profile/friendcontact',
'url' => 'http://localhost/profile/friendcontact', 'url' => 'https://friendica.local/profile/friendcontact',
'notify' => 'http://localhost/friendica/inbox', 'notify' => 'https://friendica.local/friendica/inbox',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::SHARING, 'rel' => Contact::SHARING,
@ -179,9 +170,9 @@ return [
'name' => 'Friend contact', 'name' => 'Friend contact',
'nick' => 'friendcontact', 'nick' => 'friendcontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/friendcontact', 'nurl' => 'http://friendica.local/profile/friendcontact',
'url' => 'http://localhost/profile/friendcontact', 'url' => 'https://friendica.local/profile/friendcontact',
'notify' => 'http://localhost/friendica/inbox', 'notify' => 'https://friendica.local/friendica/inbox',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::SHARING, 'rel' => Contact::SHARING,
@ -195,9 +186,9 @@ return [
'name' => 'Mutual contact', 'name' => 'Mutual contact',
'nick' => 'mutualcontact', 'nick' => 'mutualcontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/mutualcontact', 'nurl' => 'http://friendica.local/profile/mutualcontact',
'url' => 'http://localhost/profile/mutualcontact', 'url' => 'https://friendica.local/profile/mutualcontact',
'notify' => 'http://localhost/friendica/inbox', 'notify' => 'https://friendica.local/friendica/inbox',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::FRIEND, 'rel' => Contact::FRIEND,
@ -211,9 +202,9 @@ return [
'name' => 'Mutual contact', 'name' => 'Mutual contact',
'nick' => 'mutualcontact', 'nick' => 'mutualcontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/mutualcontact', 'nurl' => 'http://friendica.local/profile/mutualcontact',
'url' => 'http://localhost/profile/mutualcontact', 'url' => 'https://friendica.local/profile/mutualcontact',
'notify' => 'http://localhost/friendica/inbox', 'notify' => 'https://friendica.local/friendica/inbox',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::SHARING, 'rel' => Contact::SHARING,
@ -227,9 +218,9 @@ return [
'name' => 'Self contact', 'name' => 'Self contact',
'nick' => 'selfcontact', 'nick' => 'selfcontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/selfcontact', 'nurl' => 'http://friendica.local/profile/selfcontact',
'url' => 'http://localhost/profile/selfcontact', 'url' => 'https://friendica.local/profile/selfcontact',
'notify' => 'http://localhost/friendica/inbox', 'notify' => 'https://friendica.local/friendica/inbox',
'about' => 'User used in tests', 'about' => 'User used in tests',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
@ -240,15 +231,15 @@ return [
], ],
'apcontact' => [ 'apcontact' => [
[ [
"url" => "http://localhost/profile/selfcontact", "url" => "https://friendica.local/profile/selfcontact",
"uri-id" => 1, "uri-id" => 1,
"uuid" => "42", "uuid" => "42",
"type" => "Person", "type" => "Person",
"following" => "http://localhost/following/selfcontact", "following" => "https://friendica.local/following/selfcontact",
"followers" => "http://localhost/followers/selfcontact", "followers" => "https://friendica.local/followers/selfcontact",
"inbox" => "http://localhost/inbox/selfcontact", "inbox" => "https://friendica.local/inbox/selfcontact",
"outbox" => "http://localhost/outbox/selfcontact", "outbox" => "https://friendica.local/outbox/selfcontact",
"sharedinbox" => "http://localhost/inbox", "sharedinbox" => "https://friendica.local/inbox",
"manually-approve" => 1, "manually-approve" => 1,
"discoverable" => 0, "discoverable" => 0,
"nick" => "selfcontact", "nick" => "selfcontact",
@ -256,7 +247,7 @@ return [
"about" => "User used in tests", "about" => "User used in tests",
"xmpp" => null, "xmpp" => null,
"matrix" => null, "matrix" => null,
"photo" => "http://localhost/photo/profile/admin.jpeg", "photo" => "https://friendica.local/photo/profile/admin.jpeg",
"header" => null, "header" => null,
"addr" => "selfcontact@localhost", "addr" => "selfcontact@localhost",
"alias" => null, "alias" => null,
@ -313,32 +304,32 @@ return [
[ [
'uri-id' => 1, 'uri-id' => 1,
'body' => 'Parent status', 'body' => 'Parent status',
'plink' => 'http://localhost/display/1', 'plink' => 'https://friendica.local/display/1',
], ],
[ [
'uri-id' => 2, 'uri-id' => 2,
'body' => 'Reply', 'body' => 'Reply',
'plink' => 'http://localhost/display/2', 'plink' => 'https://friendica.local/display/2',
], ],
[ [
'uri-id' => 3, 'uri-id' => 3,
'body' => 'Other user status', 'body' => 'Other user status',
'plink' => 'http://localhost/display/3', 'plink' => 'https://friendica.local/display/3',
], ],
[ [
'uri-id' => 4, 'uri-id' => 4,
'body' => 'Friend user reply', 'body' => 'Friend user reply',
'plink' => 'http://localhost/display/4', 'plink' => 'https://friendica.local/display/4',
], ],
[ [
'uri-id' => 5, 'uri-id' => 5,
'body' => '[share]Shared status[/share]', 'body' => '[share]Shared status[/share]',
'plink' => 'http://localhost/display/5', 'plink' => 'https://friendica.local/display/5',
], ],
[ [
'uri-id' => 6, 'uri-id' => 6,
'body' => 'Friend user status', 'body' => 'Friend user status',
'plink' => 'http://localhost/display/6', 'plink' => 'https://friendica.local/display/6',
], ],
[ [
'uri-id' => 7, 'uri-id' => 7,
@ -366,7 +357,7 @@ return [
'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' . 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' . 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
'et sed beatae nihil ullam temporibus corporis ratione blanditiis', 'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
'plink' => 'http://localhost/display/6', 'plink' => 'https://friendica.local/display/6',
], ],
[ [
'uri-id' => 100, 'uri-id' => 100,
@ -919,12 +910,12 @@ return [
'id' => 1, 'id' => 1,
'type' => 8, 'type' => 8,
'name' => 'Friend contact', 'name' => 'Friend contact',
'url' => 'http://localhost/profile/friendcontact', 'url' => 'https://friendica.local/profile/friendcontact',
'photo' => 'http://localhost/', 'photo' => 'https://friendica.local/',
'date' => '2020-01-01 12:12:02', 'date' => '2020-01-01 12:12:02',
'msg' => 'A test reply from an item', 'msg' => 'A test reply from an item',
'uid' => 42, 'uid' => 42,
'link' => 'http://localhost/display/1', 'link' => 'https://friendica.local/display/1',
'iid' => 4, 'iid' => 4,
'seen' => 0, 'seen' => 0,
'verb' => \Friendica\Protocol\Activity::POST, 'verb' => \Friendica\Protocol\Activity::POST,

View File

@ -62,7 +62,7 @@ class NotificationTest extends ApiTest
$assertXml = <<<XML $assertXml = <<<XML
<?xml version="1.0"?> <?xml version="1.0"?>
<notes> <notes>
<note date="$date" date_rel="$dateRel" id="1" iid="4" link="http://localhost/display/1" msg="A test reply from an item" msg_cache="A test reply from an item" msg_html="A test reply from an item" msg_plain="A test reply from an item" name="Friend contact" name_cache="Friend contact" otype="item" parent="" photo="http://localhost/" seen="false" timestamp="1577880722" type="8" uid="42" url="http://localhost/profile/friendcontact" verb="http://activitystrea.ms/schema/1.0/post"/> <note date="$date" date_rel="$dateRel" id="1" iid="4" link="https://friendica.local/display/1" msg="A test reply from an item" msg_cache="A test reply from an item" msg_html="A test reply from an item" msg_plain="A test reply from an item" name="Friend contact" name_cache="Friend contact" otype="item" parent="" photo="https://friendica.local/" seen="false" timestamp="1577880722" type="8" uid="42" url="https://friendica.local/profile/friendcontact" verb="http://activitystrea.ms/schema/1.0/post"/>
</notes> </notes>
XML; XML;