Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,25 @@ struct SignatureVerifier {
// MARK: - PEM / Base64 helpers

private static func parsePublicKeyDER(fromPEM pem: String) throws -> Data {
let cleaned = removeAllWhitespace(data: pem)

let possibleHeaders = [
("-----BEGINPUBLICKEY-----", "-----ENDPUBLICKEY-----"),
("-----BEGINECPUBLICKEY-----", "-----ENDECPUBLICKEY-----")
("-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----"),
("-----BEGIN EC PUBLIC KEY-----", "-----END EC PUBLIC KEY-----")
]

guard let (begin, end) = possibleHeaders.first(
where: { cleaned.contains($0.0) && cleaned.contains($0.1) }
where: { (begin, end) in
pem.contains(begin) && pem.contains(end)
}
) else {
throw SignatureVerifierError.invalidPEM
}

let base64Payload = cleaned
let payload = pem
.replacing(begin, with: "")
.replacing(end, with: "")

return try decodeBase64(base64Payload)
let cleaned = removeAllWhitespace(data: payload)
return try decodeBase64(cleaned)
}

private static func decodeBase64(_ value: String) throws -> Data {
Expand All @@ -78,7 +79,7 @@ struct SignatureVerifier {
}

private static func removeAllWhitespace(data: String) -> String {
data.filter { !" \n\t\r".contains($0) }
data.filter { !$0.isWhitespace && !$0.isNewline }
}

// MARK: - ECDSA verify (curve chosen by DER length heuristic)
Expand Down
2 changes: 2 additions & 0 deletions RIADigiDoc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
DF3E4A862CE2C54600137235 /* CommonsLib */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = CommonsLib; sourceTree = "<group>"; };
DF3E4A872CE2C5B500137235 /* LibdigidocLib */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = LibdigidocLib; sourceTree = "<group>"; };
DF4E43C12D0BA38600967997 /* FileImportShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileImportShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
DF5CDD242F2BB42C002AB47F /* run-ci-tests.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "run-ci-tests.sh"; sourceTree = "<group>"; };
DF64D0E12EC363C200FF73C6 /* SmartIdLib */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = SmartIdLib; sourceTree = "<group>"; };
DF67D4F92D28531600F09EB9 /* ConfigLib */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = ConfigLib; sourceTree = "<group>"; };
DFA16B492CD18C7C0099D34F /* libdigidoclib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = libdigidoclib.xcodeproj; sourceTree = "<group>"; };
Expand Down Expand Up @@ -482,6 +483,7 @@
1A438FD12E7224CE00546B86 /* scripts */ = {
isa = PBXGroup;
children = (
DF5CDD242F2BB42C002AB47F /* run-ci-tests.sh */,
1AD26AB72E7AB14200A3629D /* build-libcdoc-sim.sh */,
1A7D36992E79EB8000CAD7A6 /* build-xcframeworks.sh */,
1A3E9ED22E79D35E00033299 /* build-openldap-iphonesimulator.sh */,
Expand Down
12 changes: 3 additions & 9 deletions codemagic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ workflows:
script: |
sh scripts/GenerateMocks.sh

xcode-project run-tests \
--project RIADigiDoc.xcodeproj \
--scheme AllTests \
--device "iPhone 17"
sh scripts/run-ci-tests.sh
when:
condition: ${{ inputs.enableTests_input }}
- name: Increment build number
Expand Down Expand Up @@ -277,12 +274,9 @@ workflows:
script: xcode-project use-profiles
- name: Run tests
script: |
sh scripts/GenerateMocks.sh
sh scripts/GenerateMocks.sh

xcode-project run-tests \
--project RIADigiDoc.xcodeproj \
--scheme AllTests \
--device "iPhone 17"
sh scripts/run-ci-tests.sh
- *get_app_version
- name: Increment build number
script: |
Expand Down
56 changes: 56 additions & 0 deletions scripts/run-ci-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh
set -e

# -----------------------------
# Config
# -----------------------------
PROJECT="RIADigiDoc.xcodeproj"
SCHEME="AllTests"
DEVICE="iPhone 17"

COMMON_ARGS=(
--project "$PROJECT"
--scheme "$SCHEME"
--device "$DEVICE"
--disable-coverage
--max-concurrent-devices 1
--max-concurrent-simulators 1
)

MODULE_GROUPS=(
"SmartIdLibTests"
"ConfigLibTests"
"MobileIdLibTests"
"LibdigidocLibTests"
"RIADigiDocTests"
"FileImportShareExtensionTests"
"UtilsLibTests"
)

# -----------------------------
# Reset simulators
# -----------------------------
echo "Shutting down and erasing all simulators..."
xcrun simctl shutdown all || true
xcrun simctl erase all || true

# -----------------------------
# Run tests group by group
# -----------------------------
for GROUP in "${MODULE_GROUPS[@]}"; do
echo "----------------------------------------"
echo "Running test group: $GROUP"
echo "----------------------------------------"

TEST_XCARGS="$COMMON_XCARGS"
for MODULE in $GROUP; do
TEST_XCARGS+=" -only-testing:${MODULE}"
done

xcode-project run-tests \
"${COMMON_ARGS[@]}" \
--test-xcargs "$TEST_XCARGS"

done

echo "All test groups completed successfully!"