mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-11-03 20:08:00 +00:00 
			
		
		
		
	add fixes according to review
This commit is contained in:
		
							parent
							
								
									91c7900d5c
								
							
						
					
					
						commit
						d0a710e31b
					
				@ -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"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -32,25 +32,25 @@ class StatusRequestorTest {
 | 
			
		||||
    private val requestor = StatusRequester()
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    fun testUpdateLocationWithAnAbsolutePath() {
 | 
			
		||||
    fun `update location - ok - absolute path`() {
 | 
			
		||||
        val newLocation = requestor.updateLocationWithRedirectPath(TEST_DOMAIN, "$TEST_DOMAIN$SUB_PATH")
 | 
			
		||||
        assertEquals("$TEST_DOMAIN$SUB_PATH", newLocation)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    fun updateLocationWithASmallerAbsolutePath() {
 | 
			
		||||
    fun `update location - ok - smaller absolute path`() {
 | 
			
		||||
        val newLocation = requestor.updateLocationWithRedirectPath("$TEST_DOMAIN$SUB_PATH", TEST_DOMAIN)
 | 
			
		||||
        assertEquals(TEST_DOMAIN, newLocation)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    fun updateLocationWithARelativePath() {
 | 
			
		||||
    fun `update location - ok - relative path`() {
 | 
			
		||||
        val newLocation = requestor.updateLocationWithRedirectPath(TEST_DOMAIN, SUB_PATH)
 | 
			
		||||
        assertEquals("$TEST_DOMAIN$SUB_PATH", newLocation)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    fun updateLocationByReplacingTheRelativePath() {
 | 
			
		||||
    fun `update location - ok - replace relative path`() {
 | 
			
		||||
        val newLocation = requestor.updateLocationWithRedirectPath(
 | 
			
		||||
            "$TEST_DOMAIN/some/other/subdir", SUB_PATH
 | 
			
		||||
        )
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user