1
0
mirror of https://github.com/owncloud/android-library.git synced 2026-08-11 16:33:03 +00:00

fix according to review

This commit is contained in:
Christian Schabesberger
2020-09-17 12:23:45 +02:00
committed by Abel García de Prada
parent 84240ef78b
commit 270e127940
4 changed files with 119 additions and 45 deletions
@@ -1,42 +1,67 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2020 ownCloud GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib
import com.owncloud.android.lib.resources.status.StatusRequestor
import com.owncloud.android.lib.resources.status.StatusRequester
import org.junit.Assert.assertEquals
import org.junit.Test
class StatusRequestorTest {
private val requestor = StatusRequestor()
private val requestor = StatusRequester()
@Test
fun `update location with an absolute path`() {
val newLocation = requestor.updateLocationWithRedirectPath(
"https://cloud.somewhere.com", "https://cloud.somewhere.com/subdir"
)
assertEquals("https://cloud.somewhere.com/subdir", newLocation)
val newLocation = requestor.updateLocationWithRedirectPath(TEST_DOMAIN, "$TEST_DOMAIN/subdir")
assertEquals("$TEST_DOMAIN$SUB_PATH", newLocation)
}
@Test
fun `update location with a smaler aboslute path`() {
val newLocation = requestor.updateLocationWithRedirectPath(
"https://cloud.somewhere.com/subdir", "https://cloud.somewhere.com/"
)
assertEquals("https://cloud.somewhere.com/", newLocation)
fun `update location with a smaller absolute path`() {
val newLocation = requestor.updateLocationWithRedirectPath("$TEST_DOMAIN$SUB_PATH", TEST_DOMAIN)
assertEquals(TEST_DOMAIN, newLocation)
}
@Test
fun `update location with a relative path`() {
val newLocation = requestor.updateLocationWithRedirectPath(
"https://cloud.somewhere.com", "/subdir"
TEST_DOMAIN, SUB_PATH
)
assertEquals("https://cloud.somewhere.com/subdir", newLocation)
assertEquals("$TEST_DOMAIN$SUB_PATH", newLocation)
}
@Test
fun `update location by replacing the relative path`() {
val newLocation = requestor.updateLocationWithRedirectPath(
"https://cloud.somewhere.com/some/other/subdir", "/subdir"
"$TEST_DOMAIN/some/other/subdir", SUB_PATH
)
assertEquals("https://cloud.somewhere.com/subdir", newLocation)
assertEquals("$TEST_DOMAIN$SUB_PATH", newLocation)
}
}
companion object {
const val TEST_DOMAIN = "https://cloud.somewhere.com"
const val SUB_PATH = "/subdir"
}
}