Merge branch 'master' into mimeicons-svg

This commit is contained in:
Robin Appelman 2014-02-21 14:00:17 +01:00
commit 3f52eb073d
20 changed files with 272 additions and 60 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
/data
/owncloud
/config/config.php
/config/*.config.php
/config/mount.php
/apps/inc.php

View file

@ -0,0 +1,71 @@
<?php
/**
* ownCloud
*
* @author Arthur Schiwon
* @copyright 2013 Arthur Schiwon blizzz@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\user_ldap\tests;
use \OCA\user_ldap\lib\Access;
use \OCA\user_ldap\lib\Connection;
use \OCA\user_ldap\lib\ILDAPWrapper;
class Test_Access extends \PHPUnit_Framework_TestCase {
private function getConnecterAndLdapMock() {
static $conMethods;
static $accMethods;
if(is_null($conMethods) || is_null($accMethods)) {
$conMethods = get_class_methods('\OCA\user_ldap\lib\Connection');
$accMethods = get_class_methods('\OCA\user_ldap\lib\Access');
}
$lw = $this->getMock('\OCA\user_ldap\lib\ILDAPWrapper');
$connector = $this->getMock('\OCA\user_ldap\lib\Connection',
$conMethods,
array($lw, null, null));
return array($lw, $connector);
}
public function testEscapeFilterPartValidChars() {
list($lw, $con) = $this->getConnecterAndLdapMock();
$access = new Access($con, $lw);
$input = 'okay';
$this->assertTrue($input === $access->escapeFilterPart($input));
}
public function testEscapeFilterPartEscapeWildcard() {
list($lw, $con) = $this->getConnecterAndLdapMock();
$access = new Access($con, $lw);
$input = '*';
$expected = '\\\\*';
$this->assertTrue($expected === $access->escapeFilterPart($input));
}
public function testEscapeFilterPartEscapeWildcard2() {
list($lw, $con) = $this->getConnecterAndLdapMock();
$access = new Access($con, $lw);
$input = 'foo*bar';
$expected = 'foo\\\\*bar';
$this->assertTrue($expected === $access->escapeFilterPart($input));
}
}

View file

@ -83,6 +83,12 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
* @return void
*/
private function prepareAccessForCheckPassword(&$access) {
$access->expects($this->once())
->method('escapeFilterPart')
->will($this->returnCallback(function($uid) {
return $uid;
}));
$access->connection->expects($this->any())
->method('__get')
->will($this->returnCallback(function($name) {
@ -116,17 +122,34 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
}));
}
public function testCheckPassword() {
public function testCheckPasswordUidReturn() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = $backend->checkPassword('roland', 'dt19');
$this->assertEquals('gunslinger', $result);
}
public function testCheckPasswordWrongPassword() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = $backend->checkPassword('roland', 'wrong');
$this->assertFalse($result);
}
public function testCheckPasswordWrongUser() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = $backend->checkPassword('mallory', 'evil');
$this->assertFalse($result);
@ -140,9 +163,23 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
$result = \OCP\User::checkPassword('roland', 'dt19');
$this->assertEquals('gunslinger', $result);
}
public function testCheckPasswordPublicAPIWrongPassword() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('roland', 'wrong');
$this->assertFalse($result);
}
public function testCheckPasswordPublicAPIWrongUser() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('mallory', 'evil');
$this->assertFalse($result);
@ -154,6 +191,12 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
* @return void
*/
private function prepareAccessForGetUsers(&$access) {
$access->expects($this->once())
->method('escapeFilterPart')
->will($this->returnCallback(function($search) {
return $search;
}));
$access->expects($this->any())
->method('getFilterPartForUserSearch')
->will($this->returnCallback(function($search) {
@ -191,28 +234,52 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
->will($this->returnArgument(0));
}
public function testGetUsers() {
public function testGetUsersNoParam() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
$result = $backend->getUsers();
$this->assertEquals(3, count($result));
}
public function testGetUsersLimitOffset() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
$result = $backend->getUsers('', 1, 2);
$this->assertEquals(1, count($result));
}
public function testGetUsersLimitOffset2() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
$result = $backend->getUsers('', 2, 1);
$this->assertEquals(2, count($result));
}
public function testGetUsersSearchWithResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
$result = $backend->getUsers('yo');
$this->assertEquals(2, count($result));
}
public function testGetUsersSearchEmptyResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
$result = $backend->getUsers('nix');
$this->assertEquals(0, count($result));
}
public function testGetUsersViaAPI() {
public function testGetUsersViaAPINoParam() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
@ -220,15 +287,43 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
$result = \OCP\User::getUsers();
$this->assertEquals(3, count($result));
}
public function testGetUsersViaAPILimitOffset() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('', 1, 2);
$this->assertEquals(1, count($result));
}
public function testGetUsersViaAPILimitOffset2() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('', 2, 1);
$this->assertEquals(2, count($result));
}
public function testGetUsersViaAPISearchWithResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('yo');
$this->assertEquals(2, count($result));
}
public function testGetUsersViaAPISearchEmptyResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('nix');
$this->assertEquals(0, count($result));

22
core/css/mobile.css Normal file
View file

@ -0,0 +1,22 @@
@media only screen and (max-width: 600px) {
/* compress search box on mobile, expand when focused */
.searchbox input[type="search"] {
width: 15%;
-webkit-transition: width 100ms;
-moz-transition: width 100ms;
-o-transition: width 100ms;
transition: width 100ms;
}
.searchbox input[type="search"]:focus,
.searchbox input[type="search"]:active {
width: 155px;
}
/* do not show display name on mobile when profile picture is present */
#header .avatardiv.avatardiv-shown + #expandDisplayName {
display: none;
}
}

View file

@ -37,11 +37,12 @@ body { background:#fefefe; font:normal .8em/1.6em "Helvetica Neue",Helvetica,Ari
.header-right { float:right; vertical-align:middle; padding:0.5em; }
.header-right > * { vertical-align:middle; }
/* Profile picture in header */
#header .avatardiv {
float: left;
display: inline-block;
margin-right: 5px;
}
#header .avatardiv img {
opacity: 1;
}
@ -218,17 +219,19 @@ textarea:disabled {
color: #bbb;
}
/* Searchbox */
.searchbox input[type="search"] {
position: relative;
font-size: 1.2em;
padding: .2em .5em .2em 1.5em;
padding-left: 1.5em;
background: #fff url('../img/actions/search.svg') no-repeat .5em center;
border: 0;
border-radius: 1em;
border-radius: 2em;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70); opacity: .7;
margin-top: 10px;
margin-top: 6px;
float: right;
}
input[type="submit"].enabled {
background: #66f866;
border: 1px solid #5e5;
@ -719,12 +722,11 @@ label.infield { cursor:text !important; top:1.05em; left:.85em; }
/* USER MENU */
#settings {
float: right;
margin-top: 7px;
margin-left: 10px;
color: #bbb;
}
#expand {
padding: 15px 15px 15px 5px;
display: block;
padding: 7px 12px 6px 7px;
cursor: pointer;
font-weight: bold;
}
@ -958,3 +960,8 @@ div.crumb:active {
opacity: 0;
}
/* for IE10 */
@-ms-viewport {
width: device-width;
}

View file

@ -1,6 +1,13 @@
$(document).ready(function(){
if (OC.currentUser) {
$('#header .avatardiv').avatar(OC.currentUser, 32, undefined, true);
var callback = function() {
// do not show display name on mobile when profile picture is present
if($('#header .avatardiv').children().length > 0) {
$('#header .avatardiv').addClass('avatardiv-shown');
}
};
$('#header .avatardiv').avatar(OC.currentUser, 32, undefined, true, callback);
// Personal settings
$('#avatar .avatardiv').avatar(OC.currentUser, 128);
}

View file

@ -24,6 +24,7 @@ foreach(OC_App::getEnabledApps() as $app) {
$array = array(
"oc_debug" => (defined('DEBUG') && DEBUG) ? 'true' : 'false',
"oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false',
"oc_webroot" => "\"".OC::$WEBROOT."\"",
"oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
"datepickerFormatDate" => json_encode($l->l('jsdate', 'jsdate')),

View file

@ -39,10 +39,15 @@
* This will behave like the first example, but it will hide the avatardiv, if
* it will display the default placeholder. undefined is the ie8fix from
* example 4 and can be either true, or false/undefined, to be ignored.
*
* 6. $('.avatardiv').avatar('jdoe', 128, undefined, true, callback);
* This will behave like the above example, but it will call the function
* defined in callback after the avatar is placed into the DOM.
*
*/
(function ($) {
$.fn.avatar = function(user, size, ie8fix, hidedefault) {
$.fn.avatar = function(user, size, ie8fix, hidedefault, callback) {
if (typeof(size) === 'undefined') {
if (this.height() > 0) {
size = this.height();
@ -91,6 +96,9 @@
$div.html('<img src="'+url+'">');
}
}
if(typeof callback === 'function') {
callback();
}
});
});
};

View file

@ -860,6 +860,7 @@ function initCore() {
// checkShowCredentials();
// $('input#user, input#password').keyup(checkShowCredentials);
// user menu
$('#settings #expand').keydown(function(event) {
if (event.which === 13 || event.which === 32) {
$('#expand').click()
@ -872,7 +873,8 @@ function initCore() {
$('#settings #expanddiv').click(function(event){
event.stopPropagation();
});
$(document).click(function(){//hide the settings menu when clicking outside it
//hide the user menu when clicking outside it
$(document).click(function(){
$('#settings #expanddiv').slideUp(200);
});

View file

@ -15,7 +15,7 @@
</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.0">
<meta name="apple-itunes-app" content="app-id=543672169">
<link rel="shortcut icon" href="<?php print_unescaped(image_path('', 'favicon.png')); ?>" />
<link rel="apple-touch-icon-precomposed" href="<?php print_unescaped(image_path('', 'favicon-touch.png')); ?>" />
@ -51,12 +51,12 @@
<div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div>
<div id="settings" class="svg">
<span id="expand" tabindex="0" role="link">
<?php if ($_['enableAvatars']): ?>
<div class="avatardiv"></div>
<?php endif; ?>
<span id="expandDisplayName"><?php p(trim($_['user_displayname']) != '' ? $_['user_displayname'] : $_['user_uid']) ?></span>
<img class="svg" alt="" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" />
</span>
<?php if ($_['enableAvatars']): ?>
<div class="avatardiv"></div>
<?php endif; ?>
<div id="expanddiv">
<ul>
<?php foreach($_['settingsnavigation'] as $entry):?>

View file

@ -332,6 +332,7 @@ class OC {
}
OC_Util::addStyle("styles");
OC_Util::addStyle("mobile");
OC_Util::addStyle("icons");
OC_Util::addStyle("apps");
OC_Util::addStyle("fixes");

View file

@ -227,6 +227,7 @@ class OC_User {
* Log in a user and regenerate a new session - if the password is ok
*/
public static function login($uid, $password) {
session_regenerate_id(true);
return self::getUserSession()->login($uid, $password);
}

View file

@ -157,7 +157,6 @@ class Session implements Emitter, \OCP\IUserSession {
if($user !== false) {
if (!is_null($user)) {
if ($user->isEnabled()) {
session_regenerate_id(true);
$this->setUser($user);
$this->setLoginName($uid);
$this->manager->emit('\OC\User', 'postLogin', array($user, $password));

View file

@ -1,20 +0,0 @@
<?php
/**
* Copyright (c) 2013 Lukas Reschke <lukas@statuscode.ch>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
// Set the content type to Javascript
header("Content-type: text/javascript");
// Disallow caching
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
if (OC_User::isAdminUser(OC_User::getUser())) {
echo("var isadmin = true;");
} else {
echo("var isadmin = false;");
}

View file

@ -52,9 +52,11 @@ function updateAvatar (hidedefault) {
if(hidedefault) {
$headerdiv.hide();
$('#header .avatardiv').removeClass('avatardiv-shown');
} else {
$headerdiv.css({'background-color': ''});
$headerdiv.avatar(OC.currentUser, 32, true);
$('#header .avatardiv').addClass('avatardiv-shown');
}
$displaydiv.css({'background-color': ''});
$displaydiv.avatar(OC.currentUser, 128, true);

View file

@ -273,7 +273,7 @@ var UserList = {
if (user === OC.currentUser && group === 'admin') {
return false;
}
if (!isadmin && checked.length === 1 && checked[0] === group) {
if (!oc_isadmin && checked.length === 1 && checked[0] === group) {
return false;
}
$.post(
@ -305,7 +305,7 @@ var UserList = {
});
};
var label;
if (isadmin) {
if (oc_isadmin) {
label = t('settings', 'add group');
} else {
label = null;

View file

@ -72,5 +72,3 @@ $this->create('settings_ajax_setloglevel', '/settings/ajax/setloglevel.php')
->actionInclude('settings/ajax/setloglevel.php');
$this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php')
->actionInclude('settings/ajax/setsecurity.php');
$this->create('isadmin', '/settings/js/isadmin.js')
->actionInclude('settings/js/isadmin.php');

View file

@ -14,8 +14,6 @@ unset($items['admin']);
$_['subadmingroups'] = array_flip($items);
?>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkToRoute('isadmin'));?>"></script>
<div id="controls">
<form id="newuser" autocomplete="off">
<input id="newusername" type="text" placeholder="<?php p($l->t('Login Name'))?>" /> <input

View file

@ -48,21 +48,6 @@ class Test_OC_Connector_Sabre_File extends PHPUnit_Framework_TestCase {
$etag = $file->put('test data');
}
/**
* Test setting name with setName()
*/
public function testSetName() {
// setup
$file = new OC_Connector_Sabre_File('/test.txt');
$file->fileView = $this->getMock('\OC\Files\View', array('isUpdatable'), array(), '', FALSE);
$file->fileView->expects($this->any())->method('isUpdatable')->withAnyParameters()->will($this->returnValue(true));
$etag = $file->put('test data');
$file->setName('/renamed.txt');
$this->assertTrue($file->fileView->file_exists('/renamed.txt'));
// clean up
$file->delete();
}
/**
* Test setting name with setName() with invalid chars
* @expectedException Sabre_DAV_Exception_BadRequest

View file

@ -0,0 +1,34 @@
<?php
/**
* Copyright (c) 2014 Bjoern Schiessle <schiessle@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
class Test_Urlgenerator extends PHPUnit_Framework_TestCase {
/**
* @small
* @brief test absolute URL construction
* @dataProvider provideURLs
*/
function testGetAbsoluteURL($url, $expectedResult) {
$urlGenerator = new \OC\URLGenerator(null);
$result = $urlGenerator->getAbsoluteURL($url);
$this->assertEquals($expectedResult, $result);
}
public function provideURLs() {
return array(
array("index.php", "http://localhost/index.php"),
array("/index.php", "http://localhost/index.php"),
array("/apps/index.php", "http://localhost/apps/index.php"),
array("apps/index.php", "http://localhost/apps/index.php"),
);
}
}