diff --git a/app/src/androidTest/java/com/nextcloud/client/account/UserAccountManagerImplTest.java b/app/src/androidTest/java/com/nextcloud/client/account/UserAccountManagerImplTest.java index 7a2fc2d385..9d80c9da20 100644 --- a/app/src/androidTest/java/com/nextcloud/client/account/UserAccountManagerImplTest.java +++ b/app/src/androidTest/java/com/nextcloud/client/account/UserAccountManagerImplTest.java @@ -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)); + } } diff --git a/app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java b/app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java index eff92e2a01..592b201810 100644 --- a/app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java +++ b/app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java @@ -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