Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen committed Apr 23, 2021
1 parent 7cc97a4 commit ba4173f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 5 deletions.
4 changes: 4 additions & 0 deletions PatientScannerDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
CE44799226306C86009A836B /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE44799126306C86009A836B /* String.swift */; };
CE44799726306C9B009A836B /* Data+Base45.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE44799626306C9B009A836B /* Data+Base45.swift */; };
CE7DE7FA2625EF18007E6694 /* SwiftCBOR in Frameworks */ = {isa = PBXBuildFile; productRef = CE7DE7F92625EF18007E6694 /* SwiftCBOR */; };
CE8912E526321AA500CB92AF /* KID.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE8912E426321AA500CB92AF /* KID.swift */; };
CEA1555D262F63B30024B7AC /* EuDgcSchema.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA1555C262F63B30024B7AC /* EuDgcSchema.swift */; };
CEA15563262F6DAB0024B7AC /* ChildDismissedDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA15562262F6DAB0024B7AC /* ChildDismissedDelegate.swift */; };
CEA1556B262F784E0024B7AC /* SelfSizedTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA1556A262F784E0024B7AC /* SelfSizedTableView.swift */; };
Expand Down Expand Up @@ -75,6 +76,7 @@
CE3CC9432628C2130079FB78 /* CBOR.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CBOR.swift; sourceTree = "<group>"; };
CE44799126306C86009A836B /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
CE44799626306C9B009A836B /* Data+Base45.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Base45.swift"; sourceTree = "<group>"; };
CE8912E426321AA500CB92AF /* KID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KID.swift; sourceTree = "<group>"; };
CEA1555C262F63B30024B7AC /* EuDgcSchema.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EuDgcSchema.swift; sourceTree = "<group>"; };
CEA15562262F6DAB0024B7AC /* ChildDismissedDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChildDismissedDelegate.swift; sourceTree = "<group>"; };
CEA1556A262F784E0024B7AC /* SelfSizedTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfSizedTableView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -153,6 +155,7 @@
CEFAD87926271414009AFEF9 /* COSE.swift */,
CE3CC9432628C2130079FB78 /* CBOR.swift */,
CE1BDF98262A4CD600766F97 /* X509.swift */,
CE8912E426321AA500CB92AF /* KID.swift */,
);
path = Services;
sourceTree = "<group>";
Expand Down Expand Up @@ -439,6 +442,7 @@
CEC2C4C22625ED030056E406 /* ZLib.swift in Sources */,
CEA15570262F79DE0024B7AC /* InfoCell.swift in Sources */,
CEA6D6EE261F8D2700715333 /* SceneDelegate.swift in Sources */,
CE8912E526321AA500CB92AF /* KID.swift in Sources */,
CE157F9B262E2A9F00FE4821 /* SwiftCBOR.CBOR.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
35 changes: 35 additions & 0 deletions PatientScannerDemo/Services/KID.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-app-ios
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*/
//
// KID.swift
// PatientScannerDemo
//
// Created by Yannick Spreen on 4/22/21.
//


import Foundation

struct KID {
public static func stringFrom(kidBytes: [UInt8]) -> String {
return Data(kidBytes.prefix(8)).base64EncodedString()
}
}
20 changes: 20 additions & 0 deletions PatientScannerDemo/ViewControllers/Scan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Vision
import AVFoundation
import SwiftCBOR
import FloatingPanel
import LocalAuthentication


class ScanVC: UIViewController {
Expand All @@ -50,6 +51,25 @@ class ScanVC: UIViewController {
// setupCameraLiveView()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.observationHandler(payloadS: nil)
// let reason = "Log in to your account"
// var context = LAContext()
// context.localizedCancelTitle = "Enter Username/Password"
// context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, error in
//
// if success {
//
// // Move to the main thread because a state update triggers UI changes.
// DispatchQueue.main.async { [unowned self] in
// print("loggedin")
// }
//
// } else {
// print(error?.localizedDescription ?? "Failed to authenticate")
//
// // Fall back to a asking for username and password.
// // ...
// }
// }
}
}
override func viewWillDisappear(_ animated: Bool) {
Expand Down
15 changes: 10 additions & 5 deletions PatientScannerDemoTests/EHNTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ class EHNTests: XCTestCase {
XCTAssert(false)
}
func testCoseEcAT() throws {
let barcode = "HC1:NCFI.L3B6AP2YQ2%MNBCHC51/CAOZDL+OL7S99U60SVOGSHD%24R4PCTH7Y9KL6EVJBIMBL364D X1KKLZ*I9K4RLDR7B011EROZS6022WR5VX4QG9W72HWCC12B:TWZG.%N8GWBCOV0O%5F9U7H 8P4L.%2/:6TXB/-J6ZJ.*QYIBYSD6/T.6RDMMK0PX6HTPO1REO*CWMFG5CJ38+FBS+8DB9*2FFP9Z8HEM137CRBQ.893$I.R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B8RCA1VP*1Q.ELZ1Q21G.JEGLOFH1:FR09$SCY/OGBU1QIE/2 9SK3"
let barcode = "HC1:NCFOXNYTS3DH$YO:CQSU40 H 804 2FI15B3LR5OGILG9N:5-RII9DL-VAD65D6 NI4EFFZSE+S.SSH2HGUS XKVD9HB58QHVM6IQ17XH0S9S-JX%EI$HGL24EGYJ2SKISE02UQHPMYO9MN9JUHLKH.O93UQFJ6GL28LHXOAYJAPRAAUICO10W59UE1YHU-H4PIUF2VSJGV4J4LV/AYVG2$436D$X40YC2ATNS4Y6TKR2*G5C%CO8TJV4423 L0VV2 73-E3ND3DAJ-432$4U1JS.S./0LWTKD33236J3TA3E-4%:K7-SN2H N37J3JFTULJ5CBP:2C 2+*4HTC/2DBAJDAJCNB-43GV4MCTKD08DJHSI PISVDGZK4EC8.SX1LC8C8DJOMI$MI-N09*0245$UH8QIBD2GMJCKH9AO2R7./HBR6$LE KMDGKRFRSGHQED10H% 0R%0D 8YIPFHL:OTEGJUY25$0P/HX$4T0H//CI+CF/8-0LO1PX$4D4TVZ0D-4VZ0S1LZ0L:M623Q$B65VCNAIO38ZIIT-ROGV86O*$2/6PSQHV-P TN3H38EU2VME.3F$MM3WYC3A1N%IFBZV3P6$A9X81M:L-5TTPNFIVD6KL/O63UX0O7V9BYEB:IB BUAA9JM:ATN.AR81Y4GP21CPVY6P:KPG:LNLL%70/6MRVMT0LV0E7*EVLS2UIU6V2M3%26%Q3J*H:5L-28SXRWUH$LCQ/S3QTY5NG.8C5MN$V4-BXJMF5RG3U6-1RDVRWNY$3/ZB3MOQDWC*08M0AV5*/0QX4B-EF0MGH5X1FYHRGX8:+RY/EI%BQ95TC5*DW/ESR4S0:1ZF59*5GK1-OH4Z6-6FUOTN*H$38IPR4GT1$OE07B*SWKN*HF83N MO.CFOW3R%GB28Z$UOH7DROI9BW/CXPS0.PS USQE:LAVZP320%R902"
return baseTestAT(barcode: barcode)
}
func baseTestAT(barcode: String) {
Expand All @@ -99,9 +99,14 @@ class EHNTests: XCTestCase {
let data = decompress(compressed)

guard
let kidBytes = CBOR.kid(from: data),
let kid = String(data: Data(kidBytes), encoding: .utf8),
let url = URL(string: "https://dev.a-sit.at/certservice/cert/\(kid)")
let kidBytes = CBOR.kid(from: data)
else {
XCTAssert(false)
return
}
let kid = KID.stringFrom(kidBytes: kidBytes)
guard
let url = URL(string: "https://dgc.a-sit.at/ehn/cert/\(kid)")
else {
XCTAssert(false)
return
Expand Down

0 comments on commit ba4173f

Please sign in to comment.