68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Copyright (c) 2013 Bjoern Schiessle <schiessle@owncloud.com>
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
* later.
|
|
* See the COPYING-README file.
|
|
*/
|
|
|
|
|
|
require_once __DIR__ . '/../lib/helper.php';
|
|
|
|
use OCA\Encryption;
|
|
|
|
/**
|
|
* Class Test_Encryption_Helper
|
|
*/
|
|
class Test_Encryption_Helper extends \PHPUnit_Framework_TestCase {
|
|
|
|
/**
|
|
* @medium
|
|
*/
|
|
function testStripPartialFileExtension() {
|
|
|
|
$partFilename = 'testfile.txt.part';
|
|
$filename = 'testfile.txt';
|
|
|
|
$this->assertTrue(Encryption\Helper::isPartialFilePath($partFilename));
|
|
|
|
$this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($partFilename));
|
|
|
|
$this->assertFalse(Encryption\Helper::isPartialFilePath($filename));
|
|
|
|
$this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($filename));
|
|
}
|
|
|
|
|
|
/**
|
|
* @medium
|
|
*/
|
|
function testStripPartialFileExtensionWithTransferIdPath() {
|
|
|
|
$partFilename = 'testfile.txt.ocTransferId643653835.part';
|
|
$filename = 'testfile.txt';
|
|
|
|
$this->assertTrue(Encryption\Helper::isPartialFilePath($partFilename));
|
|
|
|
$this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($partFilename));
|
|
|
|
$this->assertFalse(Encryption\Helper::isPartialFilePath($filename));
|
|
|
|
$this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($filename));
|
|
}
|
|
|
|
function testGetPathToRealFile() {
|
|
|
|
// the relative path to /user/files/ that's what we want to get from getPathToRealFile()
|
|
$relativePath = "foo/bar/test.txt";
|
|
|
|
// test paths
|
|
$versionPath = "/user/files_versions/foo/bar/test.txt.v456756835";
|
|
$cachePath = "/user/cache/transferid636483/foo/bar/test.txt";
|
|
|
|
$this->assertEquals($relativePath, Encryption\Helper::getPathToRealFile($versionPath));
|
|
$this->assertEquals($relativePath, Encryption\Helper::getPathToRealFile($cachePath));
|
|
}
|
|
|
|
}
|