Skip to content

Commit

Permalink
Allow developers to use Test-API (#6069)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmpoppe authored Jan 1, 2025
1 parent df50579 commit 0efc36f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,14 @@ object ApplicationConstants {
locally for performance reasons */
SplitWayAction::class
)

/*
During development it might be better to work against the Test-API, rather than the
Live-API. Developers are reminded that they need a separate login for the Test-API and
can register/logon via https://master.apis.dev.openstreetmap.org/
Note that test actions not applied to the database do not require test API (test edits that are reverted
locally before an upload etc) and that test API has a separate database that is mostly empty
(test data needs to be created there).
*/
const val USE_TEST_API = false
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.westnordost.streetcomplete.data

import de.westnordost.streetcomplete.ApplicationConstants.USE_TEST_API
import de.westnordost.streetcomplete.data.osm.edits.upload.changesets.ChangesetApiClient
import de.westnordost.streetcomplete.data.osm.edits.upload.changesets.ChangesetApiSerializer
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataApiClient
Expand All @@ -15,9 +16,14 @@ import org.koin.androidx.workmanager.dsl.worker
import org.koin.core.qualifier.named
import org.koin.dsl.module

private const val OSM_API_URL = "https://api.openstreetmap.org/api/0.6/"
private const val OSM_API_URL_LIVE = "https://api.openstreetmap.org/api/0.6/"
private const val OSM_API_URL_TEST = "https://master.apis.dev.openstreetmap.org/api/0.6/"

val OSM_API_URL =
if (USE_TEST_API) OSM_API_URL_TEST else OSM_API_URL_LIVE

val osmApiModule = module {

factory { Cleaner(get(), get(), get(), get(), get(), get()) }
factory { CacheTrimmer(get(), get()) }
factory { MapDataApiClient(get(), OSM_API_URL, get(), get(), get()) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package de.westnordost.streetcomplete.data.user

import de.westnordost.streetcomplete.ApplicationConstants.USE_TEST_API
import de.westnordost.streetcomplete.data.user.oauth.OAuthApiClient
import org.koin.dsl.module

const val OAUTH2_TOKEN_URL = "https://www.openstreetmap.org/oauth2/token"
const val OAUTH2_AUTHORIZATION_URL = "https://www.openstreetmap.org/oauth2/authorize"
private const val OAUTH2_HOST_LIVE = "https://www.openstreetmap.org/"
private const val OAUTH2_HOST_TEST = "https://master.apis.dev.openstreetmap.org/"

const val OAUTH2_CLIENT_ID = "Yyk4PmTopczrr3BWZYvLK_M-KBloCQwXgPGEzqUYTc8"
private const val OAUTH2_CLIENT_ID_LIVE = "Yyk4PmTopczrr3BWZYvLK_M-KBloCQwXgPGEzqUYTc8"
private const val OAUTH2_CLIENT_ID_TEST = "ObZ7yPf4lfs4XJ3NWysI3ukJMN0SHey1oPnNQnLmvw8"

val OAUTH2_TOKEN_URL =
(if (USE_TEST_API) OAUTH2_HOST_TEST else OAUTH2_HOST_LIVE) + "oauth2/token"
val OAUTH2_AUTHORIZATION_URL =
(if (USE_TEST_API) OAUTH2_HOST_TEST else OAUTH2_HOST_LIVE) + "oauth2/authorize"
val OAUTH2_CLIENT_ID =
if (USE_TEST_API) OAUTH2_CLIENT_ID_TEST else OAUTH2_CLIENT_ID_LIVE

const val OAUTH2_CALLBACK_SCHEME = "streetcomplete"
const val OAUTH2_CALLBACK_HOST = "oauth"
Expand Down Expand Up @@ -35,7 +44,6 @@ val OAUTH2_REQUIRED_SCOPES = listOf(
)

val userModule = module {

single<UserDataSource> { get<UserDataController>() }
single { UserDataController(get()) }

Expand Down

0 comments on commit 0efc36f

Please sign in to comment.