Skip to content

Commit

Permalink
Merge branch 'develop' into feature/ocsgw-remove-analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeterss authored Nov 22, 2019
2 parents 88e46c0 + 9acd6d5 commit d99d64b
Show file tree
Hide file tree
Showing 58 changed files with 3,627 additions and 1,110 deletions.
12 changes: 8 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
version: 2
version: 2.1
jobs:
### JOBS FOR on-feature-branch-commit PIPELINE
build-test-repo:
# machine is needed to run Gradle build and to run docker compose tests
machine:
image: ubuntu-1604:201903-01
resource_class: large
environment:
JAVA_HOME: /usr/lib/jvm/zulu13.28.11-ca-jdk13.0.1-linux_x64

Expand All @@ -18,7 +19,7 @@ jobs:
sudo tar -zxf /tmp/zulu13.28.11-ca-jdk13.0.1-linux_x64.tar.gz -C /usr/lib/jvm
- run:
# checking for merge conflicts and merging locally if none exist
name: merging ${CIRCLE_BRANCH} into develop locally
name: merging into develop locally
command: |
git config --global user.email "${GIT_USER_EMAIL}"
git config --global user.name "${GIT_USER_NAME}"
Expand Down Expand Up @@ -114,6 +115,7 @@ jobs:
build-code:
machine:
image: ubuntu-1604:201903-01
resource_class: large
environment:
JAVA_HOME: /usr/lib/jvm/zulu13.28.11-ca-jdk13.0.1-linux_x64

Expand Down Expand Up @@ -193,7 +195,8 @@ jobs:
at: ~/project

# starts a remote docker environment to run docker commands
- setup_remote_docker
- setup_remote_docker:
docker_layer_caching: true

- run:
name: build Prime docker image and push image to GCR
Expand Down Expand Up @@ -229,7 +232,8 @@ jobs:
at: ~/project

# starts a remote docker environment to run docker commands
- setup_remote_docker
- setup_remote_docker:
docker_layer_caching: true

- run:
name: build scaninfo shredder docker image and push image to GCR
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[![Kotlin version badge](https://img.shields.io/badge/kotlin-1.3.50-blue.svg)](http://kotlinlang.org/)
[![Kotlin version badge](https://img.shields.io/badge/kotlin-1.3.60-blue.svg)](http://kotlinlang.org/)
[![Prime version](https://img.shields.io/github/tag/ostelco/ostelco-core.svg)](https://github.com/ostelco/ostelco-core/tags)
[![GitHub license](https://img.shields.io/github/license/ostelco/ostelco-core.svg)](https://github.com/ostelco/ostelco-core/blob/master/LICENSE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object StripePayment {
* verify that the correspondng 'setDefaultSource' API works as
* intended.
*/
fun getDefaultSourceForCustomer(stripeCustomerId: String) : String {
fun getDefaultSourceForCustomer(customerId: String) : String {

// https://stripe.com/docs/api/java#create_source
Stripe.apiKey = System.getenv("STRIPE_API_KEY")
Expand All @@ -92,7 +92,7 @@ object StripePayment {

(0..MAX_TRIES).forEach {
try {
return Customer.retrieve(stripeCustomerId).defaultSource
return Customer.retrieve(customerId).defaultSource
} catch (e: Exception) {
error = e
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.ostelco.prime.admin.resources

import arrow.core.Either
import arrow.core.left
import arrow.core.right
import com.fasterxml.jackson.module.kotlin.readValue
import org.ostelco.prime.apierror.ApiError
import org.ostelco.prime.apierror.ApiErrorCode
Expand Down Expand Up @@ -77,7 +79,7 @@ class KYCResource {
return null
}

private fun toScanInformation(dataMap: Map<String, String>): ScanInformation? {
private fun toScanInformation(dataMap: Map<String, String>): Either<ApiError, ScanInformation> {
try {
val vendorScanReference: String = dataMap[JumioScanData.JUMIO_SCAN_ID.s]!!
var status: ScanStatus = toScanStatus(dataMap[JumioScanData.SCAN_STATUS.s]!!)
Expand Down Expand Up @@ -110,29 +112,30 @@ class KYCResource {
}
}
}
return getCountryCodeForScan(scanId)
?.let { countryCode ->
ScanInformation(
scanId,
countryCode,
status,
ScanResult(
vendorScanReference = vendorScanReference,
verificationStatus = verificationStatus,
time = time,
type = type,
country = country,
firstName = firstName,
lastName = lastName,
dob = dob,
expiry = expiry,
rejectReason = rejectReason
)
)
}
val countryCode = getCountryCodeForScan(scanId)
if (countryCode == null) {
return NotFoundError("Cannot find country for scan $scanId", ApiErrorCode.FAILED_TO_GET_COUNTRY_FOR_SCAN).left()
} else {
return ScanInformation(
scanId,
countryCode,
status,
ScanResult(
vendorScanReference = vendorScanReference,
verificationStatus = verificationStatus,
time = time,
type = type,
country = country,
firstName = firstName,
lastName = lastName,
dob = dob,
expiry = expiry,
rejectReason = rejectReason
)).right()
}
} catch (e: NullPointerException) {
logger.error("Missing mandatory fields in scan result $dataMap", e)
return null
return BadRequestError("Missing mandatory fields in scan result", ApiErrorCode.FAILED_TO_CONVERT_SCAN_RESULT).left()
}
}

Expand All @@ -144,16 +147,16 @@ class KYCResource {
@Context httpHeaders: HttpHeaders,
formData: MultivaluedMap<String, String>): Response {
dumpRequestInfo(request, httpHeaders, formData)
val scanInformation = toScanInformation(toRegularMap(formData))
if (scanInformation == null) {
logger.info("Unable to convert scan information from form data")
val reqError = BadRequestError("Missing mandatory fields in scan result", ApiErrorCode.FAILED_TO_UPDATE_SCAN_RESULTS)
return Response.status(reqError.status).entity(asJson(reqError)).build()
}
logger.info("Updating scan information ${scanInformation.scanId} jumioIdScanReference ${scanInformation.scanResult?.vendorScanReference}")
return updateScanInformation(scanInformation, formData).fold(
{ apiError -> Response.status(apiError.status).entity(asJson(apiError)) },
{ Response.status(Response.Status.OK).entity(asJson(scanInformation)) }).build()
return toScanInformation(toRegularMap(formData))
.fold({
logger.info("Unable to convert scan information from form data")
Response.status(it.status).entity(asJson(it))
}, { scanInformation ->
logger.info("Updating scan information ${scanInformation.scanId} jumioIdScanReference ${scanInformation.scanResult?.vendorScanReference}")
updateScanInformation(scanInformation, formData).fold(
{ Response.status(it.status).entity(asJson(it)) },
{ Response.status(Response.Status.OK).entity(asJson(scanInformation)) })
}).build()
}

private fun getCountryCodeForScan(scanId: String): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ data class TokenResponse(

data class ErrorResponse(val error: Error)

enum class Error {
invalid_request,
invalid_client,
invalid_grant,
unauthorized_client,
unsupported_grant_type,
invalid_scope,
enum class Error(val cause: String) {
invalid_request("The request is malformed, normally due to a missing parameter, contains an unsupported parameter, includes multiple credentials, or uses more than one mechanism for authenticating the client."),
invalid_client("The client authentication failed."),
invalid_grant("The authorization grant or refresh token is invalid."),
unauthorized_client("The client is not authorized to use this authorization grant type."),
unsupported_grant_type("The authenticated client is not authorized to use the grant type."),
invalid_scope("The requested scope is invalid."),
}

data class JWKKey(
Expand All @@ -33,4 +33,4 @@ data class JWKKey(
val use: String
)

data class JWKSet(val keys: Collection<JWKKey>)
data class JWKSet(val keys: Collection<JWKKey>)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppleIdAuthResource {
return AppleIdAuthClient.authorize(authCode.authCode)
.fold(
{
logger.warn("error: {}", it.error)
logger.warn("AppleId Auth Error Response: {}, cause: {}", it.error, it.error.error.cause)
Response.status(it.status).entity(asJson(it))
},
{ tokenResponse ->
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
id("project-report")
id("com.github.ben-manes.versions") version "0.27.0"
jacoco
kotlin("jvm") version "1.3.50" apply false
kotlin("jvm") version "1.3.60" apply false
id("com.google.protobuf") version "0.8.10" apply false
id("com.github.johnrengelman.shadow") version "5.2.0" apply false
idea
Expand Down
16 changes: 8 additions & 8 deletions buildSrc/src/main/kotlin/org/ostelco/prime/gradle/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ object Version {
const val firebase = "6.11.0"

const val googleCloud = "1.91.3"
const val googleCloudDataStore = "1.100.0"
const val googleCloudDataStore = "1.101.0"
const val googleCloudLogging = "0.116.0-alpha"
const val googleCloudPubSub = "1.100.0"
const val googleCloudStorage = "1.100.0"
const val googleCloudPubSub = "1.101.0"
const val googleCloudStorage = "1.101.0"

const val gson = "2.8.6"
const val grpc = "1.25.0"
Expand All @@ -30,10 +30,10 @@ object Version {
// Keeping it version 1.16.1 to be consistent with grpc via PubSub client lib
// Keeping it version 1.16.1 to be consistent with netty via Firebase lib
const val jaxb = "2.3.1"
const val jdbi3 = "3.10.1"
const val jdbi3 = "3.11.1"
const val jjwt = "0.10.7"
const val junit5 = "5.5.2"
const val kotlin = "1.3.50"
const val kotlin = "1.3.60"
const val kotlinXCoroutines = "1.3.2"
const val mockito = "3.1.0"
const val mockitoKotlin = "2.2.0"
Expand All @@ -46,9 +46,9 @@ object Version {
const val slf4j = "1.7.29"
// IMPORTANT: When Stripe SDK library version is updated, check if the Stripe API version has changed.
// If so, then update API version in Stripe Web Console for callback Webhooks.
const val stripe = "15.3.0"
const val swagger = "2.0.10"
const val swaggerCodegen = "2.4.9"
const val stripe = "15.4.0"
const val swagger = "2.1.0"
const val swaggerCodegen = "2.4.10"
const val testcontainers = "1.12.3"
const val tink = "1.2.2"
const val zxing = "3.4.0"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.esp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ services:

datastore-emulator:
container_name: datastore-emulator
image: google/cloud-sdk:218.0.0
image: google/cloud-sdk:272.0.0
expose:
- "8081"
environment:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.ocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ services:

datastore-emulator:
container_name: datastore-emulator
image: google/cloud-sdk:218.0.0
image: google/cloud-sdk:272.0.0
expose:
- "8081"
environment:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.seagull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ services:

datastore-emulator:
container_name: datastore-emulator
image: google/cloud-sdk:218.0.0
image: google/cloud-sdk:272.0.0
expose:
- "8081"
environment:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ services:

datastore-emulator:
container_name: datastore-emulator
image: google/cloud-sdk:218.0.0
image: google/cloud-sdk:272.0.0
expose:
- "8081"
environment:
Expand All @@ -141,7 +141,7 @@ services:
build:
context: sim-administration/postgres
dockerfile: Dockerfile
tmpfs: "//var/lib/postgresql/data"
tmpfs: "/var/lib/postgresql/data"
ports:
- "55432:5432"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,9 @@ object MyInfoClientSingleton : MyInfoKycService {
}

if (config.myInfoApiEnableSecurity && httpMethod == GET) {
// TODO vihang: Remove after initial testing is done.
logger.info("jwe PersonData: {}", content)
// logger.info("jwe PersonData: {}", content)
val jws = decodeJweCompact(content)
// TODO vihang: Remove after initial testing is done.
logger.info("jws PersonData: {}", jws)
// logger.info("jws PersonData: {}", jws)
return getPersonDataFromJwsClaims(jws)
}

Expand Down
11 changes: 10 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ module github.com/ostelco/ostelco-core
go 1.13

require (
cloud.google.com/go/logging v1.0.0
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/go-ozzo/ozzo-dbx v1.0.15
github.com/google/go-cmp v0.3.1 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/google/uuid v1.1.1
github.com/jmoiron/sqlx v1.2.0
github.com/mattn/go-sqlite3 v1.11.0
github.com/pkg/errors v0.8.1
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gotest.tools v2.2.0+incompatible
honnef.co/go/tools v0.0.1-2019.2.3 // indirect
)
Loading

0 comments on commit d99d64b

Please sign in to comment.