mirror of
https://github.com/owncloud/android-library.git
synced 2026-08-11 16:33:03 +00:00
add fixes according to review
This commit is contained in:
committed by
Abel García de Prada
parent
1c24df556d
commit
4fbf002807
+24
-24
@@ -12,22 +12,22 @@ import org.junit.Test
|
||||
class GetRemoteStatusOperationTest {
|
||||
|
||||
@Test
|
||||
fun urlStartingWithHttpMustBeDetectedAsSuch() {
|
||||
fun use_http_or_https_ok_http() {
|
||||
assertTrue(GetRemoteStatusOperation.usesHttpOrHttps(Uri.parse(HTTP_SOME_OWNCLOUD)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun urlStartingWithHttpsMustBeDetectedAsSuch() {
|
||||
fun uses_http_or_https_ok_https() {
|
||||
assertTrue(GetRemoteStatusOperation.usesHttpOrHttps(Uri.parse(HTTPS_SOME_OWNCLOUD)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun incompleteUrlWithoutHttpsOrHttpSchemeMustBeDetectedAsSuch() {
|
||||
fun use_http_or_https_ok_no_http_or_https() {
|
||||
assertFalse(GetRemoteStatusOperation.usesHttpOrHttps(Uri.parse(SOME_OWNCLOUD)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun completeUrlWithHttpMustBeReturnedAsSuch() {
|
||||
fun build_full_https_url_ok_http() {
|
||||
assertEquals(
|
||||
Uri.parse(HTTP_SOME_OWNCLOUD),
|
||||
GetRemoteStatusOperation.buildFullHttpsUrl(Uri.parse(HTTP_SOME_OWNCLOUD))
|
||||
@@ -35,7 +35,7 @@ class GetRemoteStatusOperationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun completeUrlWithHttpsMustBeReturnedAsSuch() {
|
||||
fun build_full_https_url_ok_https() {
|
||||
assertEquals(
|
||||
Uri.parse(HTTPS_SOME_OWNCLOUD),
|
||||
GetRemoteStatusOperation.buildFullHttpsUrl(Uri.parse(HTTPS_SOME_OWNCLOUD))
|
||||
@@ -43,7 +43,7 @@ class GetRemoteStatusOperationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun incompleteUrlWithoutHttpPrefixMustBeConvertedToProperUrlWithHttpsPrefix() {
|
||||
fun build_full_https_url_ok_no_prefix() {
|
||||
assertEquals(
|
||||
Uri.parse(HTTPS_SOME_OWNCLOUD),
|
||||
GetRemoteStatusOperation.buildFullHttpsUrl(Uri.parse(SOME_OWNCLOUD))
|
||||
@@ -51,7 +51,7 @@ class GetRemoteStatusOperationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun completeUrlWithSubdirAndHttpsMustBeReturnedAsSuch() {
|
||||
fun build_full_https_url_ok_no_https_with_subdir() {
|
||||
assertEquals(
|
||||
Uri.parse(HTTPS_SOME_OWNCLOUD_WITH_SUBDIR), GetRemoteStatusOperation.buildFullHttpsUrl(
|
||||
Uri.parse(
|
||||
@@ -62,7 +62,7 @@ class GetRemoteStatusOperationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun incompleteUrlWithSubdirAndWithoutHttpPrefixMustBeConvertedToProperUrlWithHttpsPrefix() {
|
||||
fun build_full_https_url_ok_no_prefix_with_subdir() {
|
||||
assertEquals(
|
||||
Uri.parse(HTTPS_SOME_OWNCLOUD_WITH_SUBDIR), GetRemoteStatusOperation.buildFullHttpsUrl(
|
||||
Uri.parse(
|
||||
@@ -73,17 +73,17 @@ class GetRemoteStatusOperationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun ipMustBeConvertedToProperUrl() {
|
||||
fun build_full_https_url_ok_ip() {
|
||||
assertEquals(Uri.parse(HTTPS_SOME_IP), GetRemoteStatusOperation.buildFullHttpsUrl(Uri.parse(SOME_IP)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun urlContainingIpAndHttpPrefixMustBeReturnedAsSuch() {
|
||||
fun build_full_https_url_http_ip() {
|
||||
assertEquals(Uri.parse(HTTP_SOME_IP), GetRemoteStatusOperation.buildFullHttpsUrl(Uri.parse(HTTP_SOME_IP)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun ipAndPortMustBeConvertedToProperUrl() {
|
||||
fun build_full_https_url_ok_ip_with_port() {
|
||||
assertEquals(
|
||||
Uri.parse(HTTPS_SOME_IP_WITH_PORT),
|
||||
GetRemoteStatusOperation.buildFullHttpsUrl(Uri.parse(SOME_IP_WITH_PORT))
|
||||
@@ -91,7 +91,7 @@ class GetRemoteStatusOperationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun urlContainingIpAndPortAndHttpPrefixMustBeReturnedAsSuch() {
|
||||
fun build_full_https_url_ok_ip_with_http_and_port() {
|
||||
assertEquals(
|
||||
Uri.parse(HTTP_SOME_IP_WITH_PORT),
|
||||
GetRemoteStatusOperation.buildFullHttpsUrl(Uri.parse(HTTP_SOME_IP_WITH_PORT))
|
||||
@@ -99,20 +99,20 @@ class GetRemoteStatusOperationTest {
|
||||
}
|
||||
|
||||
companion object {
|
||||
val SOME_OWNCLOUD = "some_owncloud.com"
|
||||
val HTTP_SOME_OWNCLOUD = "$HTTP_PREFIX$SOME_OWNCLOUD"
|
||||
val HTTPS_SOME_OWNCLOUD = "$HTTPS_PREFIX$SOME_OWNCLOUD"
|
||||
const val SOME_OWNCLOUD = "some_owncloud.com"
|
||||
const val HTTP_SOME_OWNCLOUD = "$HTTP_PREFIX$SOME_OWNCLOUD"
|
||||
const val HTTPS_SOME_OWNCLOUD = "$HTTPS_PREFIX$SOME_OWNCLOUD"
|
||||
|
||||
val SOME_OWNCLOUD_WITH_SUBDIR = "some_owncloud.com/subdir"
|
||||
val HTTP_SOME_OWNCLOUD_WITH_SUBDIR = "$HTTP_PREFIX$SOME_OWNCLOUD_WITH_SUBDIR"
|
||||
val HTTPS_SOME_OWNCLOUD_WITH_SUBDIR = "$HTTPS_PREFIX$SOME_OWNCLOUD_WITH_SUBDIR"
|
||||
const val SOME_OWNCLOUD_WITH_SUBDIR = "some_owncloud.com/subdir"
|
||||
const val HTTP_SOME_OWNCLOUD_WITH_SUBDIR = "$HTTP_PREFIX$SOME_OWNCLOUD_WITH_SUBDIR"
|
||||
const val HTTPS_SOME_OWNCLOUD_WITH_SUBDIR = "$HTTPS_PREFIX$SOME_OWNCLOUD_WITH_SUBDIR"
|
||||
|
||||
val SOME_IP = "184.123.185.12"
|
||||
val HTTP_SOME_IP = "$HTTP_PREFIX$SOME_IP"
|
||||
val HTTPS_SOME_IP = "$HTTPS_PREFIX$SOME_IP"
|
||||
const val SOME_IP = "184.123.185.12"
|
||||
const val HTTP_SOME_IP = "$HTTP_PREFIX$SOME_IP"
|
||||
const val HTTPS_SOME_IP = "$HTTPS_PREFIX$SOME_IP"
|
||||
|
||||
val SOME_IP_WITH_PORT = "184.123.185.12:5678"
|
||||
val HTTP_SOME_IP_WITH_PORT = "$HTTP_PREFIX$SOME_IP_WITH_PORT"
|
||||
val HTTPS_SOME_IP_WITH_PORT = "$HTTPS_PREFIX$SOME_IP_WITH_PORT"
|
||||
const val SOME_IP_WITH_PORT = "184.123.185.12:5678"
|
||||
const val HTTP_SOME_IP_WITH_PORT = "$HTTP_PREFIX$SOME_IP_WITH_PORT"
|
||||
const val HTTPS_SOME_IP_WITH_PORT = "$HTTPS_PREFIX$SOME_IP_WITH_PORT"
|
||||
}
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
/* 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.StatusRequester
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class StatusRequestorTest {
|
||||
private val requestor = StatusRequester()
|
||||
|
||||
@Test
|
||||
fun testUpdateLocationWithAnAbsolutePath() {
|
||||
val newLocation = requestor.updateLocationWithRedirectPath(TEST_DOMAIN, "$TEST_DOMAIN$SUB_PATH")
|
||||
assertEquals("$TEST_DOMAIN$SUB_PATH", newLocation)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateLocationWithASmallerAbsolutePath() {
|
||||
val newLocation = requestor.updateLocationWithRedirectPath("$TEST_DOMAIN$SUB_PATH", TEST_DOMAIN)
|
||||
assertEquals(TEST_DOMAIN, newLocation)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateLocationWithARelativePath() {
|
||||
val newLocation = requestor.updateLocationWithRedirectPath(TEST_DOMAIN, SUB_PATH)
|
||||
assertEquals("$TEST_DOMAIN$SUB_PATH", newLocation)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateLocationByReplacingTheRelativePath() {
|
||||
val newLocation = requestor.updateLocationWithRedirectPath(
|
||||
"$TEST_DOMAIN/some/other/subdir", SUB_PATH
|
||||
)
|
||||
assertEquals("$TEST_DOMAIN$SUB_PATH", newLocation)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TEST_DOMAIN = "https://cloud.somewhere.com"
|
||||
const val SUB_PATH = "/subdir"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user