- mid commit

Took 4 hours 2 minutes
This commit is contained in:
2023-05-12 16:26:15 +01:00
parent 243a20a9c4
commit 068bd2068e
19 changed files with 199 additions and 13 deletions

View File

@@ -7,4 +7,8 @@ const val deleteAccountFirebase =
"http://10.0.2.2:9099/identitytoolkit.googleapis.com/v1/accounts:delete?key=$apiKey"
const val USER_PASSWORD = "LetMeIn123!"
const val USER_PASSWORD = "LetMeIn123!"
const val DRIVER_EMAIL = "existing-driver@driver.com"
const val ADMIN_EMAIL = "admin@driver.com"
const val PASSWORD = "test123456"

View File

@@ -0,0 +1,56 @@
package h_mal.appttude.com.driver.firebase.api
import h_mal.appttude.com.driver.firebase.model.*
import okhttp3.OkHttpClient
import okhttp3.Request
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PUT
import retrofit2.http.Query
interface FirebaseApi {
@PUT("v1/accounts:signUp")
suspend fun signUp(@Body request: SignUpRequest): Response<SignUpResponse>
@PUT("v1/accounts:signInWithPassword")
suspend fun signInWithPassword(@Body request: SignUpRequest): Response<SignUpResponse>
@PUT("v1/accounts:sendOobCode")
suspend fun sendOobCode(@Body request: Map<String, String>): Response<OobCodeResponse>
@PUT("v1/accounts:resetPassword")
suspend fun resetPassword(@Body request: ResetPasswordRequest): Response<ResetPasswordResponse>
// invoke method creating an invocation of the api call
companion object{
operator fun invoke() : FirebaseApi {
val host = "10.0.2.2"
val baseUrl = "http://$host:9099/identitytoolkit.googleapis.com/"
val okkHttpclient = OkHttpClient.Builder()
.addInterceptor {
val original = it.request()
val url = original.url.newBuilder()
.addQueryParameter("key", "apikeydfasdfasdfasdf")
.build()
val requestBuilder = original.newBuilder().url(url)
val request: Request = requestBuilder.build()
it.proceed(request)
}
.build()
// creation of retrofit class
return Retrofit.Builder()
.client(okkHttpclient)
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(FirebaseApi::class.java)
}
}
}

View File

@@ -0,0 +1,38 @@
package h_mal.appttude.com.driver.firebase.api
import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import okhttp3.Interceptor
import java.io.IOException
class NetworkConnectionInterceptor(
context: Context
) : Interceptor {
private val applicationContext = context.applicationContext
override fun intercept(chain: Interceptor.Chain): okhttp3.Response {
if (!isInternetAvailable()){
throw IOException("Make sure you have an active data connection")
}
return chain.proceed(chain.request())
}
private fun isInternetAvailable(): Boolean {
var result = false
val connectivityManager =
applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager?
connectivityManager?.let {
it.getNetworkCapabilities(connectivityManager.activeNetwork)?.apply {
result = when {
hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
else -> false
}
}
}
return result
}
}

View File

@@ -0,0 +1,9 @@
package h_mal.appttude.com.driver.firebase.model
data class OobCodeResponse(
val kind: String? = null,
val oobLink: String? = null,
val oobCode: String? = null,
val email: String? = null
)

View File

@@ -0,0 +1,10 @@
package h_mal.appttude.com.driver.firebase.model
data class ResetPasswordRequest(
val oldPassword: String? = null,
val tenantId: String? = null,
val newPassword: String? = null,
val oobCode: String? = null,
val email: String? = null
)

View File

@@ -0,0 +1,9 @@
package h_mal.appttude.com.driver.firebase.model
data class ResetPasswordResponse(
val requestType: String? = null,
val kind: String? = null,
val newEmail: String? = null,
val email: String? = null
)

View File

@@ -0,0 +1,7 @@
package h_mal.appttude.com.driver.firebase.model
data class SignUpRequest(
val password: String? = null,
val email: String? = null
)

View File

@@ -1,4 +1,4 @@
package h_mal.appttude.com.driver.firebase
package h_mal.appttude.com.driver.firebase.model
data class SignUpResponse(
val expiresIn: String? = null,

View File

@@ -0,0 +1,24 @@
package h_mal.appttude.com.driver.robots
import h_mal.appttude.com.driver.BaseTestRobot
import h_mal.appttude.com.driver.R
fun login(func: LoginRobot.() -> Unit) = LoginRobot().apply { func() }
class LoginRobot : BaseTestRobot() {
fun setEmail(email: String?) = fillEditText(R.id.email, email)
fun setPassword(pass: String) = fillEditText(R.id.password, pass)
fun clickLogin() = clickButton(R.id.email_sign_in_button)
fun clickRegister() = clickButton(R.id.register_button)
fun clickForgotPassword() = clickButton(R.id.forgot)
fun checkEmailError(err: String) = checkErrorOnTextEntry(R.id.email, err)
fun checkPasswordError(err: String) = checkErrorOnTextEntry(R.id.password, err)
}

View File

@@ -0,0 +1,27 @@
package h_mal.appttude.com.driver.robots
import h_mal.appttude.com.driver.BaseTestRobot
import h_mal.appttude.com.driver.R
fun register(func: RegisterRobot.() -> Unit) = RegisterRobot().apply { func() }
class RegisterRobot : BaseTestRobot() {
fun setName(name: String) = fillEditText(R.id.name_register, name)
fun setEmail(email: String) = fillEditText(R.id.email_register, email)
fun setPassword(pass: String) = fillEditText(R.id.password_top, pass)
fun setPasswordConfirm(pass: String) = fillEditText(R.id.password_bottom, pass)
fun clickLogin() = clickButton(R.id.email_sign_up)
fun checkNameError(err: String) = checkErrorOnTextEntry(R.id.name_register, err)
fun checkEmailError(err: String) = checkErrorOnTextEntry(R.id.email_register, err)
fun checkPasswordError(err: String) = checkErrorOnTextEntry(R.id.password_top, err)
fun checkPasswordConfirmError(err: String) = checkErrorOnTextEntry(R.id.password_bottom, err)
}