Skip to content

Commit

Permalink
chore: fix ktlint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pklawikowski-schibsted committed Oct 1, 2024
1 parent ce99f2c commit e44a7ef
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
*
* From: https://github.com/openid/AppAuth-Android
* Notable changes:
* * Rewritten from Java to Kotlin.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.schibsted.account.webflows.activities
/*
* Copyright 2015 The AppAuth for Android Authors. All Rights Reserved.
*
Expand All @@ -10,17 +11,13 @@
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
*
* From: https://github.com/openid/AppAuth-Android
* Notable changes:
* * Rewritten from Java to Kotlin.
* * Updated code comments.
*/

package com.schibsted.account.webflows.activities

import android.app.Activity
import android.os.Bundle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ package com.schibsted.account.webflows.api

import com.nimbusds.jose.jwk.JWKSet
import retrofit2.Call
import retrofit2.http.*
import retrofit2.http.Field
import retrofit2.http.FieldMap
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path

internal interface SchibstedAccountService {
@Headers("X-OIDC: v1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.google.gson.annotations.JsonAdapter
import com.google.gson.annotations.SerializedName
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import java.util.*
import java.util.Locale

data class UserProfileResponse(
val uuid: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import java.util.Date
* Crawls through the obfuscated session JSON to find the access token to enable auto log-in.
*/

// TODO: remove Logs and printlns after RC build is accepted.
internal object ObfuscatedSessionFinder {
private const val USER_TOKENS_KEY = "userTokens"
private const val REFRESH_TOKEN_KEY = "refreshToken"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.schibsted.account.webflows.token

import com.schibsted.account.webflows.api.*
import com.schibsted.account.webflows.api.HttpError
import com.schibsted.account.webflows.api.RefreshTokenRequest
import com.schibsted.account.webflows.api.SchibstedAccountApi
import com.schibsted.account.webflows.api.UserTokenRequest
import com.schibsted.account.webflows.api.UserTokenResponse
import com.schibsted.account.webflows.client.AuthState
import com.schibsted.account.webflows.client.ClientConfiguration
import com.schibsted.account.webflows.jose.AsyncJwks
import com.schibsted.account.webflows.jose.RemoteJwks
import com.schibsted.account.webflows.token.TokenError.*
import com.schibsted.account.webflows.util.Either
import com.schibsted.account.webflows.util.Either.Left
import com.schibsted.account.webflows.util.Either.Right
Expand Down Expand Up @@ -61,15 +64,15 @@ internal class TokenHandler(
.onSuccess { handleTokenResponse(it, authState, callback) }
.onFailure { err ->
Timber.d("Token request error response: $err")
callback(Left(TokenRequestError(err)))
callback(Left(TokenError.TokenRequestError(err)))
}
}
}

fun makeTokenRequest(
refreshToken: String,
scope: String? = null,
): Either<TokenRequestError, UserTokenResponse> {
): Either<TokenError.TokenRequestError, UserTokenResponse> {
val tokenRequest =
RefreshTokenRequest(
refreshToken,
Expand All @@ -80,7 +83,7 @@ internal class TokenHandler(
is Right -> result
is Left -> {
Timber.d("Token request error response: ${result.value}")
Left(TokenRequestError(result.value))
Left(TokenError.TokenRequestError(result.value))
}
}
}
Expand All @@ -93,7 +96,7 @@ internal class TokenHandler(
val idToken = tokenResponse.id_token
if (idToken == null) {
Timber.e("Missing ID Token")
callback(Left(NoIdTokenReceived))
callback(Left(TokenError.NoIdTokenReceived))
return
}

Expand Down Expand Up @@ -125,7 +128,7 @@ internal class TokenHandler(
),
)
}
.onFailure { callback(Left(IdTokenNotValid(it))) }
.onFailure { callback(Left(TokenError.IdTokenNotValid(it))) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ package com.schibsted.account.webflows.user

import com.schibsted.account.webflows.util.Either.Left
import com.schibsted.account.webflows.util.Either.Right
import okhttp3.*
import okhttp3.Authenticator
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response
import okhttp3.Route
import timber.log.Timber

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import com.schibsted.account.webflows.util.Either
import com.schibsted.account.webflows.util.Either.Left
import com.schibsted.account.webflows.util.Either.Right
import kotlinx.parcelize.Parcelize
import okhttp3.*
import okhttp3.Call
import okhttp3.Callback
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import timber.log.Timber
import java.io.IOException
import java.net.URL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.schibsted.account.webflows.client

import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test

class OAuthErrorTest {
Expand Down

0 comments on commit e44a7ef

Please sign in to comment.