mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Merge pull request #11567 from nextcloud/nmc/fileOwnerNameIgnoreCase
Fix file owner and account name check ignore case.
This commit is contained in:
commit
a139938300
2 changed files with 25 additions and 1 deletions
|
@ -7,6 +7,7 @@ import android.os.Bundle;
|
|||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
|
@ -48,4 +49,25 @@ public class UserAccountManagerImplTest extends AbstractOnServerIT {
|
|||
// assume that userId == loginname (as we manually set it)
|
||||
assertEquals(userId, accountManager.getUserData(account, AccountUtils.Constants.KEY_USER_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkName() {
|
||||
UserAccountManagerImpl sut = new UserAccountManagerImpl(targetContext, accountManager);
|
||||
|
||||
Account owner = new Account("John@nextcloud.local", "nextcloud");
|
||||
Account account1 = new Account("John@nextcloud.local", "nextcloud");
|
||||
Account account2 = new Account("john@nextcloud.local", "nextcloud");
|
||||
|
||||
OCFile file1 = new OCFile("/test1.pdf");
|
||||
file1.setOwnerId("John");
|
||||
|
||||
assertTrue(sut.accountOwnsFile(file1, owner));
|
||||
assertTrue(sut.accountOwnsFile(file1, account1));
|
||||
assertTrue(sut.accountOwnsFile(file1, account2));
|
||||
|
||||
file1.setOwnerId("john");
|
||||
assertTrue(sut.accountOwnsFile(file1, owner));
|
||||
assertTrue(sut.accountOwnsFile(file1, account1));
|
||||
assertTrue(sut.accountOwnsFile(file1, account2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* @author TSI-mc
|
||||
* Copyright (C) 2019 Chris Narkiewicz
|
||||
* Copyright (C) 2023 TSI-mc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
|
@ -340,7 +342,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
|||
@Override
|
||||
public boolean accountOwnsFile(OCFile file, Account account) {
|
||||
final String ownerId = file.getOwnerId();
|
||||
return TextUtils.isEmpty(ownerId) || account.name.split("@")[0].equals(ownerId);
|
||||
return TextUtils.isEmpty(ownerId) || account.name.split("@")[0].equalsIgnoreCase(ownerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue