Skip to content

Commit 84bc1c7

Browse files
committed
[RELEASE] Version 10.1.1 with TATAPI subfolder and an actual TATAPI test
Related: https://projekte.in2code.de/issues/48078
2 parents 7368eb5 + d428b8c commit 84bc1c7

File tree

6 files changed

+201
-8
lines changed

6 files changed

+201
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# In2publish Core Change Log
22

3+
10.1.1:
4+
5+
- [META] Set the EM conf version number to 10.1.1
6+
- [BUGFIX] Use subfolder inside of typo3temp to allow symlinking the location
7+
- [BUGFIX] Add missing test to assert that the TATAPI works as expected
8+
- [RELEASE] Version 10.1.0 with consolidated tasks API, redirect filter and admin DB compare tool
9+
310
10.1.0:
411

512
- [META] Set the branch alias version number to 10.1.x-dev

Classes/Communication/TemporaryAssetTransmission/AssetTransmitter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function transmitTemporaryFile(string $source): string
8888
}
8989
}
9090

91-
$target = $this->foreignRootPath . '/typo3temp/' . uniqid('tx_in2publishcore_temp_', false);
91+
$target = $this->foreignRootPath . '/typo3temp/tx_in2publishcore/' . uniqid('tx_in2publishcore_temp_', false);
9292

9393
$success = $this->adapter->copyFileToRemote($source, $target);
9494

Classes/Testing/Tests/Adapter/TransmissionAdapterTest.php

Lines changed: 138 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,160 @@
2929
* This copyright notice MUST APPEAR in all copies of the script!
3030
*/
3131

32+
use In2code\In2publishCore\Communication\RemoteCommandExecution\RemoteCommandDispatcher;
33+
use In2code\In2publishCore\Communication\RemoteCommandExecution\RemoteCommandRequest;
34+
use In2code\In2publishCore\Communication\RemoteCommandExecution\RemoteCommandResponse;
35+
use In2code\In2publishCore\Communication\TemporaryAssetTransmission\AssetTransmitter;
3236
use In2code\In2publishCore\Communication\TemporaryAssetTransmission\TransmissionAdapter\AdapterInterface;
37+
use In2code\In2publishCore\Testing\Tests\Configuration\ConfigurationFormatTest;
3338
use In2code\In2publishCore\Testing\Tests\TestCaseInterface;
3439
use In2code\In2publishCore\Testing\Tests\TestResult;
40+
use Throwable;
41+
use TYPO3\CMS\Core\Utility\GeneralUtility;
3542

3643
use function array_merge;
44+
use function bin2hex;
45+
use function file_put_contents;
46+
use function is_file;
47+
use function random_bytes;
48+
use function register_shutdown_function;
49+
use function strpos;
50+
use function uniqid;
51+
use function unlink;
3752

3853
class TransmissionAdapterTest implements TestCaseInterface
3954
{
55+
/** @var AssetTransmitter */
56+
protected $assetTransmitter;
57+
58+
/** @var RemoteCommandDispatcher */
59+
protected $remoteCommandDispatcher;
60+
61+
public function __construct(AssetTransmitter $assetTransmitter, RemoteCommandDispatcher $remoteCommandDispatcher)
62+
{
63+
$this->assetTransmitter = $assetTransmitter;
64+
$this->remoteCommandDispatcher = $remoteCommandDispatcher;
65+
}
66+
4067
public function run(): TestResult
4168
{
42-
return new TestResult('adapter.all_transmission_adapter_tests__passed');
69+
try {
70+
$canary = bin2hex(random_bytes(16));
71+
} catch (Throwable $e) {
72+
$canary = uniqid('tx_in2publishcore_test_', true);
73+
}
74+
$localTmpFile = GeneralUtility::tempnam('tx_in2publishlocal_test_', '.txt');
75+
file_put_contents($localTmpFile, $canary);
76+
register_shutdown_function(static function () use ($localTmpFile) {
77+
if (is_file($localTmpFile)) {
78+
unlink($localTmpFile);
79+
}
80+
});
81+
82+
try {
83+
$foreignTmpFile = $this->assetTransmitter->transmitTemporaryFile($localTmpFile);
84+
} catch (Throwable $exception) {
85+
return new TestResult(
86+
'LLL:EXT:in2publish_core/Resources/Private/Language/locallang.testing.xlf:adapter.transmission.asset_transmitter_error',
87+
TestResult::ERROR,
88+
[(string)$exception]
89+
);
90+
}
91+
92+
GeneralUtility::unlink_tempfile($localTmpFile);
93+
94+
$getContentResponse = $this->getForeignFileContents($foreignTmpFile);
95+
if (!$getContentResponse->isSuccessful()) {
96+
$needle = 'cat: ' . $foreignTmpFile . ': No such file or directory';
97+
if (false !== strpos($getContentResponse->getErrorsString(), $needle)) {
98+
return new TestResult(
99+
'LLL:EXT:in2publish_core/Resources/Private/Language/locallang.testing.xlf:adapter.transmission.file_not_transferred',
100+
TestResult::ERROR,
101+
[$getContentResponse->getOutputString(), $getContentResponse->getErrorsString()]
102+
);
103+
}
104+
$rmResponse = $this->removeForeignFile($foreignTmpFile);
105+
if ($rmResponse->isSuccessful()) {
106+
return new TestResult(
107+
'LLL:EXT:in2publish_core/Resources/Private/Language/locallang.testing.xlf:adapter.transmission.file_cat_failed',
108+
TestResult::ERROR,
109+
[$getContentResponse->getOutputString(), $getContentResponse->getErrorsString()]
110+
);
111+
}
112+
return new TestResult(
113+
'LLL:EXT:in2publish_core/Resources/Private/Language/locallang.testing.xlf:adapter.transmission.file_cat_failed_manual_remove',
114+
TestResult::ERROR,
115+
[
116+
$getContentResponse->getOutputString(),
117+
$getContentResponse->getErrorsString(),
118+
$rmResponse->getOutputString(),
119+
$rmResponse->getErrorsString(),
120+
],
121+
[$foreignTmpFile]
122+
);
123+
}
124+
125+
$rmResponse = $this->removeForeignFile($foreignTmpFile);
126+
127+
if ($getContentResponse->getOutputString() !== $canary) {
128+
if ($rmResponse->isSuccessful()) {
129+
return new TestResult(
130+
'LLL:EXT:in2publish_core/Resources/Private/Language/locallang.testing.xlf:adapter.transmission.content_altered',
131+
TestResult::ERROR,
132+
[$getContentResponse->getOutputString(), $getContentResponse->getErrorsString()]
133+
);
134+
}
135+
return new TestResult(
136+
'LLL:EXT:in2publish_core/Resources/Private/Language/locallang.testing.xlf:adapter.transmission.content_altered_manual_remove',
137+
TestResult::ERROR,
138+
[
139+
'Expected: "' . $canary . '"',
140+
'Actual: "' . $getContentResponse->getOutputString() . '"',
141+
$getContentResponse->getErrorsString(),
142+
$rmResponse->getOutputString(),
143+
$rmResponse->getErrorsString(),
144+
],
145+
[$foreignTmpFile]
146+
);
147+
}
148+
149+
if (!$rmResponse->isSuccessful()) {
150+
return new TestResult(
151+
'LLL:EXT:in2publish_core/Resources/Private/Language/locallang.testing.xlf:adapter.transmission.file_deletion_failed',
152+
TestResult::ERROR,
153+
[$rmResponse->getOutputString(), $rmResponse->getErrorsString()],
154+
[$foreignTmpFile]
155+
);
156+
}
157+
158+
return new TestResult(
159+
'LLL:EXT:in2publish_core/Resources/Private/Language/locallang.testing.xlf:adapter.transmission.all_tests_passed'
160+
);
161+
}
162+
163+
protected function removeForeignFile(string $foreignTmpFile): RemoteCommandResponse
164+
{
165+
$rceRequest = new RemoteCommandRequest('rm', [], [$foreignTmpFile]);
166+
$rceRequest->setDispatcher('');
167+
$rceRequest->usePhp(false);
168+
169+
return $this->remoteCommandDispatcher->dispatch($rceRequest);
170+
}
171+
172+
protected function getForeignFileContents(string $foreignTmpFile): RemoteCommandResponse
173+
{
174+
$rceRequest = new RemoteCommandRequest('cat', [], [$foreignTmpFile]);
175+
$rceRequest->setDispatcher('');
176+
$rceRequest->usePhp(false);
177+
178+
return $this->remoteCommandDispatcher->dispatch($rceRequest);
43179
}
44180

45181
/** @SuppressWarnings(PHPMD.Superglobals) */
46182
public function getDependencies(): array
47183
{
48184
$dependencies = [
185+
ConfigurationFormatTest::class,
49186
AdapterSelectionTest::class,
50187
];
51188
if (isset($GLOBALS['in2publish_core']['virtual_tests'][AdapterInterface::class])) {

Resources/Private/Language/de.locallang.testing.xlf

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,37 @@
517517

518518
<!-- \In2code\In2publishCore\Testing\Tests\Adapter\TransmissionAdapterTest -->
519519

520-
<trans-unit id="adapter.all_transmission_adapter_tests__passed">
521-
<source>All adapter tests for the TATAPI component have passed</source>
522-
<target state="translated">Alle Adaptertests für die TATAPI-Komponente waren erfolgreich</target>
520+
<trans-unit id="adapter.transmission.all_tests_passed">
521+
<source>TATAPI: All adapter tests for the TATAPI component have passed and a file has been transferred successfully.</source>
522+
<target state="translated">TATAPI: Alle Adaptertests für die TATAPI-Komponente waren erfolgreich und eine Datei konnte erfolgreich übertragen werden.</target>
523+
</trans-unit>
524+
<trans-unit id="adapter.transmission.asset_transmitter_error">
525+
<source>TATAPI: Error in asset transmitter</source>
526+
<target state="translated">TATAPI: Ein Fehler im AssetTransmitter ist aufgetreten</target>
527+
</trans-unit>
528+
<trans-unit id="adapter.transmission.file_not_transferred">
529+
<source>TATAPI: The file has not been transferred</source>
530+
<target state="translated">TATAPI: Die Datei wurde nicht übertragen</target>
531+
</trans-unit>
532+
<trans-unit id="adapter.transmission.file_cat_failed">
533+
<source>TATAPI: Checking the file on foreign failed</source>
534+
<target state="translated">TATAPI: Beim überprüfen der übertragenen Datei ist ein Fehler aufgetreten</target>
535+
</trans-unit>
536+
<trans-unit id="adapter.transmission.file_cat_failed_manual_remove">
537+
<source xml:space="preserve">TATAPI: Checking the file on foreign failed. Please delete the file %s on foreign manually</source>
538+
<target state="translated" xml:space="preserve">TATAPI: Beim überprüfen der übertragenen Datei ist ein Fehler aufgetreten. Bitte löschen Sie dei Datei %s manuell auf dem entfernten System</target>
539+
</trans-unit>
540+
<trans-unit id="adapter.transmission.content_altered">
541+
<source xml:space="preserve">TATAPI: The file has been copied to foreign but the files contents are altered</source>
542+
<target state="translated" xml:space="preserve">TATAPI: Die Datei wurde übertragen, jedoch wurde bei der Übertragung der Inhalt geändert.</target>
543+
</trans-unit>
544+
<trans-unit id="adapter.transmission.content_altered_manual_remove">
545+
<source xml:space="preserve">TATAPI: The file has been copied to foreign but the files contents are altered. The file could not be deleted after this test. Please delete the file %s on foreign manually</source>
546+
<target state="translated" xml:space="preserve">TATAPI: Die Datei wurde übertragen, jedoch wurde bei der Übertragung der Inhalt geändert. Die Datei konnte nach diesem Test nicht gelöscht werden. Bitte löschen Sie dei Datei %s manuell auf dem entfernten System</target>
547+
</trans-unit>
548+
<trans-unit id="adapter.transmission.file_deletion_failed">
549+
<source xml:space="preserve">TATAPI: The transmission was successful, but the deletion of the temporary file on foreign failed. Please delete the file %s on foreign manually</source>
550+
<target state="translated" xml:space="preserve">TATAPI: Der Dateiübrtagungstest war erfolgreich, jedoch konnte die Testdatei nach diesem Test nicht gelöscht werden. Bitte löschen Sie dei Datei %s manuell auf dem entfernten System</target>
523551
</trans-unit>
524552

525553
<!-- \In2code\In2publishCore\Testing\Tests\Adapter\AdapterSelectionTest -->

Resources/Private/Language/locallang.testing.xlf

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,29 @@
411411

412412
<!-- \In2code\In2publishCore\Testing\Tests\Adapter\TransmissionAdapterTest -->
413413

414-
<trans-unit id="adapter.all_transmission_adapter_tests__passed">
415-
<source>All adapter tests for the TATAPI component have passed</source>
414+
<trans-unit id="adapter.transmission.all_tests_passed">
415+
<source>TATAPI: All adapter tests for the TATAPI component have passed and a file has been transferred successfully.</source>
416+
</trans-unit>
417+
<trans-unit id="adapter.transmission.asset_transmitter_error">
418+
<source>TATAPI: Error in asset transmitter</source>
419+
</trans-unit>
420+
<trans-unit id="adapter.transmission.file_not_transferred">
421+
<source>TATAPI: The file has not been transferred</source>
422+
</trans-unit>
423+
<trans-unit id="adapter.transmission.file_cat_failed">
424+
<source>TATAPI: Checking the file on foreign failed</source>
425+
</trans-unit>
426+
<trans-unit id="adapter.transmission.file_cat_failed_manual_remove">
427+
<source xml:space="preserve">TATAPI: Checking the file on foreign failed. Please delete the file %s on foreign manually</source>
428+
</trans-unit>
429+
<trans-unit id="adapter.transmission.content_altered">
430+
<source xml:space="preserve">TATAPI: The file has been copied to foreign but the files contents are altered</source>
431+
</trans-unit>
432+
<trans-unit id="adapter.transmission.content_altered_manual_remove">
433+
<source xml:space="preserve">TATAPI: The file has been copied to foreign but the files contents are altered. The file could not be deleted after this test. Please delete the file %s on foreign manually</source>
434+
</trans-unit>
435+
<trans-unit id="adapter.transmission.file_deletion_failed">
436+
<source xml:space="preserve">TATAPI: The transmission was successful, but the deletion of the temporary file on foreign failed. Please delete the file %s on foreign manually</source>
416437
</trans-unit>
417438

418439
<!-- \In2code\In2publishCore\Testing\Tests\Adapter\AdapterSelectionTest -->

ext_emconf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'title' => 'in2publish Core',
77
'description' => 'Content publishing extension to connect stage and production server',
88
'category' => 'plugin',
9-
'version' => '10.1.0',
9+
'version' => '10.1.1',
1010
'state' => 'stable',
1111
'uploadfolder' => 0,
1212
'createDirs' => '',

0 commit comments

Comments
 (0)