Skip to content

Commit 19d07de

Browse files
authored
Merge pull request #99 from odaridavid/resolve-cleartext
Resolve cleartext errors
2 parents e53ac71 + 6b4bce8 commit 19d07de

File tree

8 files changed

+45
-16
lines changed

8 files changed

+45
-16
lines changed

app/google-services.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
},
1616
"oauth_client": [
1717
{
18-
"client_id": "564324081859-pp0b62lk19reni5p538ckse2dr6dr3li.apps.googleusercontent.com",
18+
"client_id": "564324081859-1mq6f3s6a23k45romp1uepctunruou5p.apps.googleusercontent.com",
1919
"client_type": 1,
2020
"android_info": {
2121
"package_name": "com.k0d4black.theforce",
22-
"certificate_hash": "113cb837d7d15580c33a4d642ff301877a14b840"
22+
"certificate_hash": "2ed02f3b703354a87ed8fdf61772ccf523a4e339"
2323
}
2424
},
2525
{
@@ -51,6 +51,14 @@
5151
}
5252
},
5353
"oauth_client": [
54+
{
55+
"client_id": "564324081859-0asij4ni6kmpr6cp9i798vmhipoqtrps.apps.googleusercontent.com",
56+
"client_type": 1,
57+
"android_info": {
58+
"package_name": "com.k0d4black.theforce.debug",
59+
"certificate_hash": "113cb837d7d15580c33a4d642ff301877a14b840"
60+
}
61+
},
5462
{
5563
"client_id": "564324081859-4udbte4ljtq9upkgevouj8rf32albjbr.apps.googleusercontent.com",
5664
"client_type": 3

app/src/androidTest/kotlin/com/k0d4black/theforce/helpers/StarWarsRequestDispatcher.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ internal class StarWarsRequestDispatcher : Dispatcher() {
1313

1414
override fun dispatch(request: RecordedRequest): MockResponse {
1515
return when (request.path) {
16-
"/people?search=$EXISTING_SEARCH_PARAMS" -> {
16+
"/people/?search=$EXISTING_SEARCH_PARAMS" -> {
1717
MockResponse()
1818
.setResponseCode(HttpURLConnection.HTTP_OK)
1919
.setBody(searchSuccess)
2020
}
21-
"/people?search=$NON_EXISTENT_SEARCH_PARAMS" -> {
21+
"/people/?search=$NON_EXISTENT_SEARCH_PARAMS" -> {
2222
MockResponse()
2323
.setResponseCode(HttpURLConnection.HTTP_OK)
2424
.setBody(searchNoMatch)
2525
}
26-
"/people?search=$ERROR_SEARCH_PARAMS" -> {
26+
"/people/?search=$ERROR_SEARCH_PARAMS" -> {
2727
MockResponse()
2828
.setResponseCode(HttpURLConnection.HTTP_NOT_FOUND)
2929
.setBody(notFound)

app/src/release/res/xml/network_security_config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
-->
1414
<network-security-config>
15-
<domain-config cleartextTrafficPermitted="true">
15+
<domain-config cleartextTrafficPermitted="false">
1616
<domain includeSubdomains="true">swapi.dev</domain>
1717
</domain-config>
1818
</network-security-config>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
*
3+
* Copyright 2020 David Odari
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License. You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software distributed under the License
9+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
* or implied. See the License for the specific language governing permissions and limitations under
11+
* the License.
12+
*
13+
**/
14+
package com.k0d4black.theforce.data.remote
15+
16+
17+
fun String.enforceHttps(): String =
18+
if (!this.contains("https"))
19+
this.replace("http", "https")
20+
else this

data-remote/src/main/kotlin/com/k0d4black/theforce/data/remote/api/StarWarsApiService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import retrofit2.http.Url
77

88
interface StarWarsApiService {
99

10-
@GET("people")
10+
@GET("people/")
1111
suspend fun searchCharacters(@Query("search") params: String): SearchResponse
1212

1313
@GET

data-remote/src/main/kotlin/com/k0d4black/theforce/data/remote/repository/CharacterDetailsRepository.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.k0d4black.theforce.data.remote.repository
22

33
import com.k0d4black.theforce.data.remote.api.StarWarsApiService
4+
import com.k0d4black.theforce.data.remote.enforceHttps
45
import com.k0d4black.theforce.data.remote.mappers.toDomain
56
import com.k0d4black.theforce.domain.models.Film
67
import com.k0d4black.theforce.domain.models.Planet
@@ -14,26 +15,26 @@ class CharacterDetailsRepository(
1415
) : ICharacterDetailsRepository {
1516

1617
override suspend fun getCharacterPlanet(characterUrl: String): Flow<Planet> = flow {
17-
val planetResponse = apiService.getPlanet(characterUrl)
18-
val planet = apiService.getPlanetDetails(planetResponse.homeworldUrl)
18+
val planetResponse = apiService.getPlanet(characterUrl.enforceHttps())
19+
val planet = apiService.getPlanetDetails(planetResponse.homeworldUrl.enforceHttps())
1920
emit(planet.toDomain())
2021
}
2122

2223
override suspend fun getCharacterSpecies(characterUrl: String): Flow<List<Specie>> = flow {
23-
val speciesResponse = apiService.getSpecies(characterUrl)
24+
val speciesResponse = apiService.getSpecies(characterUrl.enforceHttps())
2425
val species = mutableListOf<Specie>()
2526
for (specieUrl in speciesResponse.specieUrls) {
26-
val specie = apiService.getSpecieDetails(specieUrl)
27+
val specie = apiService.getSpecieDetails(specieUrl.enforceHttps())
2728
species.add(specie.toDomain())
2829
}
2930
emit(species)
3031
}
3132

3233
override suspend fun getCharacterFilms(characterUrl: String): Flow<List<Film>> = flow {
33-
val filmsResponse = apiService.getFilms(characterUrl)
34+
val filmsResponse = apiService.getFilms(characterUrl.enforceHttps())
3435
val films = mutableListOf<Film>()
3536
for (filmUrl in filmsResponse.filmUrls) {
36-
val film = apiService.getFilmDetails(filmUrl)
37+
val film = apiService.getFilmDetails(filmUrl.enforceHttps())
3738
films.add(film.toDomain())
3839
}
3940
emit(films)

data-remote/src/test/kotlin/com/k0d4black/theforce/data/remote/helpers/StarWarsRequestDispatcher.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ internal class StarWarsRequestDispatcher : Dispatcher() {
3232

3333
override fun dispatch(request: RecordedRequest): MockResponse {
3434
return when (request.path) {
35-
"/people?search=$EXISTING_SEARCH_PARAMS" -> {
35+
"/people/?search=$EXISTING_SEARCH_PARAMS" -> {
3636
MockResponse()
3737
.setResponseCode(HttpURLConnection.HTTP_OK)
3838
.setBody(getJson("json/character_search.json"))
3939
}
40-
"/people?search=$NON_EXISTENT_SEARCH_PARAMS" -> {
40+
"/people/?search=$NON_EXISTENT_SEARCH_PARAMS" -> {
4141
MockResponse()
4242
.setResponseCode(HttpURLConnection.HTTP_OK)
4343
.setBody(

dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ext {
88
//App Versioning
99
versionCodeMajor = 2
1010
versionCodeMinor = 1
11-
versionCodePatch = 0
11+
versionCodePatch = 1
1212
versionName = "$versionCodeMajor.$versionCodeMinor.$versionCodePatch"
1313

1414
//Dependencies Version - Presentation

0 commit comments

Comments
 (0)