Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 602ab41

Browse files
authored
Merge pull request #555 from owncloud/feature/auth_webfinger_flow
Update WebFinger flow
2 parents fa65c1a + 3a27baa commit 602ab41

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/webfinger/GetInstancesViaWebFingerOperation.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,17 @@ class GetInstancesViaWebFingerOperation(
7575
val response = parseResponse(rawResponse)
7676
Timber.d("Successful WebFinger request: $response")
7777
val operationResult = RemoteOperationResult<List<String>>(RemoteOperationResult.ResultCode.OK)
78-
operationResult.data = response.links.map { it.href }
78+
operationResult.data = response.links?.map { it.href } ?: listOf()
7979
return operationResult
8080
}
8181

8282
override fun run(client: OwnCloudClient): RemoteOperationResult<List<String>> {
8383
val requestUri = buildRequestUri()
8484
val getMethod = GetMethod(URL(requestUri.toString()))
85+
86+
// First iteration won't follow redirections.
87+
getMethod.followRedirects = false
88+
8589
return try {
8690
val status = client.executeHttpMethod(getMethod)
8791
val response = getMethod.getResponseBodyAsString()!!

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/webfinger/responses/WebFingerResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import com.squareup.moshi.JsonClass
2929
@JsonClass(generateAdapter = true)
3030
data class WebFingerResponse(
3131
val subject: String,
32-
val links: List<LinkItem>
32+
val links: List<LinkItem>?
3333
)
3434

3535
@JsonClass(generateAdapter = true)

owncloudComLibrary/src/test/java/com/owncloud/android/lib/resources/webfinger/responses/WebFingerResponseTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ class WebFingerResponseTest {
2222
@Test
2323
fun `check rel in too much information - ok`() {
2424
val response = loadResponses(TOO_MUCH_INFORMATION_JSON)!!
25-
Assert.assertEquals("https://gast.somedomain.de", response.links[0].href)
26-
Assert.assertEquals("http://webfinger.owncloud/rel/server-instance", response.links[0].rel)
25+
Assert.assertEquals("https://gast.somedomain.de", response.links!![0].href)
26+
Assert.assertEquals("http://webfinger.owncloud/rel/server-instance", response.links!![0].rel)
2727
}
2828

2929
@Test(expected = JsonDataException::class)
3030
fun `check key value pairs - ko - no href key`() {
3131
val response = loadResponses(BROKEN_JSON)!!
32-
Assert.assertEquals("https://gast.somedomain.de", response.links[0].href)
32+
Assert.assertEquals("https://gast.somedomain.de", response.links!![0].href)
3333
}
3434

3535
@Test(expected = JsonDataException::class)
3636
fun `check key value pairs - ko - no rel key`() {
3737
val response = loadResponses(BROKEN_JSON)!!
38-
Assert.assertEquals("https://gast.somedomain.de", response.links[0].href)
38+
Assert.assertEquals("https://gast.somedomain.de", response.links!![0].href)
3939
}
4040

4141
companion object {

0 commit comments

Comments
 (0)