-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #996 from nextcloud/fix/double-slash
NextcloudUriDelegate: avoid double-slash in files dav paths
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
library/src/androidTest/java/com/nextcloud/common/NextcloudUriDelegateIT.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.nextcloud.common | ||
|
||
import android.net.Uri | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class NextcloudUriDelegateIT { | ||
|
||
lateinit var sut: NextcloudUriDelegate | ||
|
||
@Before | ||
fun setUp() { | ||
sut = NextcloudUriDelegate(Uri.parse(BASEURL), USERID) | ||
} | ||
|
||
@Test | ||
fun testFilesDavUri_leadingSlashInPath() { | ||
val expected = "$EXPECTED_FILES_DAV/path/to/file.txt" | ||
val actual = sut.getFilesDavUri("/path/to/file.txt") | ||
Assert.assertEquals("Wrong URL", expected, actual) | ||
} | ||
|
||
@Test | ||
fun testFilesDavUri_noLeadingSlashInPath() { | ||
val expected = "$EXPECTED_FILES_DAV/path/to/file.txt" | ||
val actual = sut.getFilesDavUri("path/to/file.txt") | ||
Assert.assertEquals("Wrong URL", expected, actual) | ||
} | ||
|
||
@Test | ||
fun testFilesDavUri_emptyPath() { | ||
val expected = "$EXPECTED_FILES_DAV/" | ||
val actual = sut.getFilesDavUri("") | ||
Assert.assertEquals("Wrong URL", expected, actual) | ||
} | ||
|
||
@Test | ||
fun testFilesDavUri_rootPath() { | ||
val expected = "$EXPECTED_FILES_DAV/" | ||
val actual = sut.getFilesDavUri("/") | ||
Assert.assertEquals("Wrong URL", expected, actual) | ||
} | ||
|
||
companion object { | ||
private const val USERID = "user" | ||
private const val BASEURL = "http://test.localhost" | ||
private const val EXPECTED_FILES_DAV = "$BASEURL/remote.php/dav/files/$USERID" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters