Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4904 from corona-warn-app/fix/otp-srs-response-pr…
Browse files Browse the repository at this point in the history
…operties-receive-model-date

Fix/SRS submitting works own SRS model type (with string)
  • Loading branch information
30mar authored Nov 30, 2022
2 parents b52c38e + 31104cd commit efb2da5
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 22 deletions.
12 changes: 8 additions & 4 deletions src/xcode/ENA/ENA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@
8FB7C92B2750EF6E0071C98C /* TicketValidationServiceIdentityDocumentValidationDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FB7C9252750EF6E0071C98C /* TicketValidationServiceIdentityDocumentValidationDecorator.swift */; };
8FB7C92D2750EF6E0071C98C /* TicketValidationDecoratorIdentityDocumentProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FB7C9272750EF6E0071C98C /* TicketValidationDecoratorIdentityDocumentProcessor.swift */; };
8FBF34AA28BD1C4F000A86D7 /* OTPAuthorizationForELSResource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FBF34A928BD1C4F000A86D7 /* OTPAuthorizationForELSResource.swift */; };
8FBF34AE28BD1CD5000A86D7 /* OTPResponsePropertiesReceiveModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FBF34AD28BD1CD5000A86D7 /* OTPResponsePropertiesReceiveModel.swift */; };
8FBF34AE28BD1CD5000A86D7 /* OTPForELSResponsePropertiesReceiveModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FBF34AD28BD1CD5000A86D7 /* OTPForELSResponsePropertiesReceiveModel.swift */; };
8FD5BE21292BB95400B0315B /* SRSService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FD5BE20292BB95400B0315B /* SRSService.swift */; };
8FD7E2C927E9EABD00E08ABB /* CCLServiceInvalidationRulesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FD7E2C827E9EABD00E08ABB /* CCLServiceInvalidationRulesTests.swift */; };
8FDB9403261FBA3800BA8CB1 /* RapidTestQRCodeInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FDB9402261FBA3800BA8CB1 /* RapidTestQRCodeInformation.swift */; };
Expand Down Expand Up @@ -1752,6 +1752,7 @@
DC03798C28F4483C00E1EE20 /* HomeLinkCardViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC03798B28F4483B00E1EE20 /* HomeLinkCardViewModelTests.swift */; };
DC03798E28F449D000E1EE20 /* HomeLinkCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC03798D28F449D000E1EE20 /* HomeLinkCard.swift */; };
DC28F7C828FEC94100EFFA34 /* UIImage+SFSymbols.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC28F7C728FEC94100EFFA34 /* UIImage+SFSymbols.swift */; };
DC29CBAA29376D6800BEAA79 /* OTPForSRSResponsePropertiesReceiveModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC29CBA929376D6800BEAA79 /* OTPForSRSResponsePropertiesReceiveModel.swift */; };
DC3B278F28F5936700A55769 /* NSAttributedString+Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3B278E28F5936700A55769 /* NSAttributedString+Image.swift */; };
DC4618C429155B2F0035CAA7 /* SRSTestTypeSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4618C329155B2F0035CAA7 /* SRSTestTypeSelectionViewController.swift */; };
DC4618C629155E560035CAA7 /* SRSTestTypeSelectionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4618C529155E560035CAA7 /* SRSTestTypeSelectionViewModel.swift */; };
Expand Down Expand Up @@ -2949,7 +2950,7 @@
8FB7C9252750EF6E0071C98C /* TicketValidationServiceIdentityDocumentValidationDecorator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TicketValidationServiceIdentityDocumentValidationDecorator.swift; sourceTree = "<group>"; };
8FB7C9272750EF6E0071C98C /* TicketValidationDecoratorIdentityDocumentProcessor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TicketValidationDecoratorIdentityDocumentProcessor.swift; sourceTree = "<group>"; };
8FBF34A928BD1C4F000A86D7 /* OTPAuthorizationForELSResource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OTPAuthorizationForELSResource.swift; sourceTree = "<group>"; };
8FBF34AD28BD1CD5000A86D7 /* OTPResponsePropertiesReceiveModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OTPResponsePropertiesReceiveModel.swift; sourceTree = "<group>"; };
8FBF34AD28BD1CD5000A86D7 /* OTPForELSResponsePropertiesReceiveModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OTPForELSResponsePropertiesReceiveModel.swift; sourceTree = "<group>"; };
8FD5BE20292BB95400B0315B /* SRSService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SRSService.swift; sourceTree = "<group>"; };
8FD7E2C827E9EABD00E08ABB /* CCLServiceInvalidationRulesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCLServiceInvalidationRulesTests.swift; sourceTree = "<group>"; };
8FDB9402261FBA3800BA8CB1 /* RapidTestQRCodeInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RapidTestQRCodeInformation.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3656,6 +3657,7 @@
DC03798B28F4483B00E1EE20 /* HomeLinkCardViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeLinkCardViewModelTests.swift; sourceTree = "<group>"; };
DC03798D28F449D000E1EE20 /* HomeLinkCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeLinkCard.swift; sourceTree = "<group>"; };
DC28F7C728FEC94100EFFA34 /* UIImage+SFSymbols.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+SFSymbols.swift"; sourceTree = "<group>"; };
DC29CBA929376D6800BEAA79 /* OTPForSRSResponsePropertiesReceiveModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OTPForSRSResponsePropertiesReceiveModel.swift; sourceTree = "<group>"; };
DC3B278C28F55B6D00A55769 /* SAP_Internal_Stats_LinkCard+Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SAP_Internal_Stats_LinkCard+Mock.swift"; sourceTree = "<group>"; };
DC3B278E28F5936700A55769 /* NSAttributedString+Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSAttributedString+Image.swift"; sourceTree = "<group>"; };
DC4618C329155B2F0035CAA7 /* SRSTestTypeSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SRSTestTypeSelectionViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7371,6 +7373,7 @@
isa = PBXGroup;
children = (
8F2FA2E4292B2D8400C6286A /* OTPAuthorizationForSRSResource.swift */,
DC29CBA929376D6800BEAA79 /* OTPForSRSResponsePropertiesReceiveModel.swift */,
);
path = OTPAuthorizationForSRS;
sourceTree = "<group>";
Expand Down Expand Up @@ -7582,7 +7585,7 @@
children = (
5001DE8B26E20C4B004242FA /* AuthorizeOtpEls.swift */,
8FBF34A928BD1C4F000A86D7 /* OTPAuthorizationForELSResource.swift */,
8FBF34AD28BD1CD5000A86D7 /* OTPResponsePropertiesReceiveModel.swift */,
8FBF34AD28BD1CD5000A86D7 /* OTPForELSResponsePropertiesReceiveModel.swift */,
);
path = OTPAuthorizationForELS;
sourceTree = "<group>";
Expand Down Expand Up @@ -11631,6 +11634,7 @@
BAF0A3E326A6EBCB0043CA84 /* DSCListProviding.swift in Sources */,
B1D431CB246C84A400E728AD /* DownloadedPackagesStoreV1.swift in Sources */,
714194EA247A65C60072A090 /* DynamicTableViewHeaderSeparatorView.swift in Sources */,
DC29CBAA29376D6800BEAA79 /* OTPForSRSResponsePropertiesReceiveModel.swift in Sources */,
50FA072B26023784003C1E46 /* TraceWarningPackageDownload.swift in Sources */,
BA16BBF327B2BFD700C21B87 /* SerialSecureCacheMigrator.swift in Sources */,
BA258CB0281AB7A3002C56D4 /* Locator+AvailableHours.swift in Sources */,
Expand Down Expand Up @@ -11883,7 +11887,7 @@
B1B381432472EF8B0056BEEE /* HTTPClient+Configuration.swift in Sources */,
0138F70825F679AC00A9B075 /* TraceLocationConfigurationViewController.swift in Sources */,
ABD4310127FC83800063666C /* HealthCertificateRevocationEntries.swift in Sources */,
8FBF34AE28BD1CD5000A86D7 /* OTPResponsePropertiesReceiveModel.swift in Sources */,
8FBF34AE28BD1CD5000A86D7 /* OTPForELSResponsePropertiesReceiveModel.swift in Sources */,
017AD14625A4546400FA2B3F /* UITableViewController+Enum.swift in Sources */,
EBB92C72259E10ED00013B41 /* UpdateOSViewController.swift in Sources */,
DC7002D9284F6B7900B164AC /* HealthCertificateExportCertificatesInfoViewModel.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ struct OTPAuthorizationForELSResource: Resource {

self.locator = .authorizeOtpEls()
self.type = .default
self.receiveResource = JSONReceiveResource<OTPResponsePropertiesReceiveModel>()
self.receiveResource = JSONReceiveResource<OTPForELSResponsePropertiesReceiveModel>()
self.trustEvaluation = trustEvaluation
}

// MARK: - Protocol Resource

typealias Send = ProtobufSendResource<SAP_Internal_Ppdd_ELSOneTimePasswordRequestIOS>
typealias Receive = JSONReceiveResource<OTPResponsePropertiesReceiveModel>
typealias Receive = JSONReceiveResource<OTPForELSResponsePropertiesReceiveModel>
typealias CustomError = OTPAuthorizationError

let trustEvaluation: TrustEvaluating

var locator: Locator
var type: ServiceType
var sendResource: ProtobufSendResource<SAP_Internal_Ppdd_ELSOneTimePasswordRequestIOS>
var receiveResource: JSONReceiveResource<OTPResponsePropertiesReceiveModel>
var receiveResource: JSONReceiveResource<OTPForELSResponsePropertiesReceiveModel>

func customError(
for error: ServiceError<OTPAuthorizationError>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import Foundation

struct OTPResponsePropertiesReceiveModel: Codable {
struct OTPForELSResponsePropertiesReceiveModel: Codable {
let expirationDate: Date?
let errorCode: PPAServerErrorCode?
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ struct OTPAuthorizationForSRSResource: Resource {

self.locator = .authorizeOtpSrs(isFake: false)
self.type = .default
self.receiveResource = JSONReceiveResource<OTPResponsePropertiesReceiveModel>()
self.receiveResource = JSONReceiveResource<OTPForSRSResponsePropertiesReceiveModel>()
self.trustEvaluation = trustEvaluation
}

// MARK: - Protocol Resource

typealias Send = ProtobufSendResource<SAP_Internal_Ppdd_SRSOneTimePasswordRequestIOS>
typealias Receive = JSONReceiveResource<OTPResponsePropertiesReceiveModel>
typealias Receive = JSONReceiveResource<OTPForSRSResponsePropertiesReceiveModel>
typealias CustomError = OTPAuthorizationError

let trustEvaluation: TrustEvaluating

var locator: Locator
var type: ServiceType
var sendResource: ProtobufSendResource<SAP_Internal_Ppdd_SRSOneTimePasswordRequestIOS>
var receiveResource: JSONReceiveResource<OTPResponsePropertiesReceiveModel>
var receiveResource: JSONReceiveResource<OTPForSRSResponsePropertiesReceiveModel>

func customError(
for error: ServiceError<OTPAuthorizationError>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// 🦠 Corona-Warn-App
//

import Foundation

struct OTPForSRSResponsePropertiesReceiveModel: Codable {
let expirationDate: String?
let errorCode: PPAServerErrorCode?
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class ELSServiceTests: CWATestCase {
let riskProvider = MockRiskProvider()
let loadResource = LoadResource(
result: .success(
OTPResponsePropertiesReceiveModel(
OTPForELSResponsePropertiesReceiveModel(
expirationDate: Date(),
errorCode: nil)
),
Expand Down
11 changes: 9 additions & 2 deletions src/xcode/ENA/ENA/Source/Services/OTP/OTPService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,19 @@ final class OTPService: OTPServiceProviding {
}

switch result {
case .success(let expirationDate):
case .success(let otpForSRSResponsePropertiesReceiveModel):
guard let expirationDateString = otpForSRSResponsePropertiesReceiveModel.expirationDate,
let expirationDate = ISO8601DateFormatter.justUTCDateFormatter.date(from: expirationDateString)
else {
completion(.failure(.restServiceError(.receivedResourceError(.invalidResponseError))))
return
}

// Success: We store the authorized otp with timestamp and return the token.
let verifiedToken = OTPToken(
token: otp,
timestamp: Date(),
expirationDate: expirationDate.expirationDate
expirationDate: expirationDate
)

self.store.otpTokenSrs = verifiedToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class OTPServiceTests: CWATestCase {
let riskProvider = MockRiskProvider()
let loadResource = LoadResource(
result: .success(
OTPResponsePropertiesReceiveModel(
OTPForELSResponsePropertiesReceiveModel(
expirationDate: Date(),
errorCode: nil)
),
Expand Down Expand Up @@ -309,7 +309,7 @@ class OTPServiceTests: CWATestCase {
let riskProvider = MockRiskProvider()
let loadResource = LoadResource(
result: .success(
OTPResponsePropertiesReceiveModel(
OTPForELSResponsePropertiesReceiveModel(
expirationDate: Date(),
errorCode: nil)
),
Expand Down Expand Up @@ -355,7 +355,7 @@ class OTPServiceTests: CWATestCase {
let riskProvider = MockRiskProvider()
let loadResource = LoadResource(
result: .success(
OTPResponsePropertiesReceiveModel(
OTPForELSResponsePropertiesReceiveModel(
expirationDate: Date(),
errorCode: nil)
),
Expand Down Expand Up @@ -402,7 +402,7 @@ class OTPServiceTests: CWATestCase {
let riskProvider = MockRiskProvider()
let loadResource = LoadResource(
result: .success(
OTPResponsePropertiesReceiveModel(
OTPForELSResponsePropertiesReceiveModel(
expirationDate: Date(),
errorCode: nil)
),
Expand Down Expand Up @@ -449,7 +449,7 @@ class OTPServiceTests: CWATestCase {
let riskProvider = MockRiskProvider()
let loadResource = LoadResource(
result: .success(
OTPResponsePropertiesReceiveModel(
OTPForELSResponsePropertiesReceiveModel(
expirationDate: Date(),
errorCode: nil)
),
Expand Down Expand Up @@ -496,7 +496,7 @@ class OTPServiceTests: CWATestCase {
let riskProvider = MockRiskProvider()
let loadResource = LoadResource(
result: .success(
OTPResponsePropertiesReceiveModel(
OTPForELSResponsePropertiesReceiveModel(
expirationDate: Date(),
errorCode: nil)
),
Expand Down Expand Up @@ -544,7 +544,7 @@ class OTPServiceTests: CWATestCase {
let riskProvider = MockRiskProvider()
let loadResource = LoadResource(
result: .success(
OTPResponsePropertiesReceiveModel(
OTPForELSResponsePropertiesReceiveModel(
expirationDate: Date(),
errorCode: nil)
),
Expand Down Expand Up @@ -593,7 +593,7 @@ class OTPServiceTests: CWATestCase {
let riskProvider = MockRiskProvider()
let loadResource = LoadResource(
result: .success(
OTPResponsePropertiesReceiveModel(
OTPForELSResponsePropertiesReceiveModel(
expirationDate: Date(),
errorCode: nil)
),
Expand Down

0 comments on commit efb2da5

Please sign in to comment.