Skip to content

Commit

Permalink
Adjust tests after fixing SwiftLint warnings + switch to Ubuntu-based…
Browse files Browse the repository at this point in the history
… SwiftLint on CI
  • Loading branch information
Jeehut committed May 23, 2024
1 parent b7ecc1a commit e64fae3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ on:
jobs:
lint:
name: Lint Code
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@v4
- name: Lint
run: swiftlint
uses: norio-nomura/[email protected]
with:
args: --strict
test:
name: Test Xcode ${{ matrix.xcode }} - ${{ matrix.xcodebuildCommand }}
runs-on: "macos-latest"
Expand Down
4 changes: 2 additions & 2 deletions Sources/TelemetryClient/SignalManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal class SignalManager: SignalManageable {
let signalPostBody = SignalPostBody(
receivedAt: Date(),
appID: UUID(uuidString: configuration.telemetryAppID)!,
clientUser: CryptoHashing.sha256(str: customUserID ?? self.defaultUserIdentifier, salt: configuration.salt),
clientUser: CryptoHashing.sha256(string: customUserID ?? self.defaultUserIdentifier, salt: configuration.salt),
sessionID: configuration.sessionID.uuidString,
type: "\(signalName)",
floatValue: floatValue,
Expand Down Expand Up @@ -203,7 +203,7 @@ private extension SignalManager {
#if os(macOS)
/// A custom ``UserDefaults`` instance specific to TelemetryDeck and the current application.
private var customDefaults: UserDefaults? {
let appIdHash = CryptoHashing.sha256(str: self.configuration.telemetryAppID, salt: "")
let appIdHash = CryptoHashing.sha256(string: self.configuration.telemetryAppID, salt: "")
return UserDefaults(suiteName: "com.telemetrydeck.\(appIdHash.suffix(12))")
}
#endif
Expand Down
8 changes: 4 additions & 4 deletions Tests/TelemetryClientTests/CryptoHashingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class CryptoHashingTests: XCTestCase {

let expectedDigestString = "5b8fab7cf45fcece0e99a05950611b7b355917e4fb6daa73fd3d7590764fa53b"

XCTAssertEqual(expectedDigestString, CryptoHashing.sha256(str: stringToHash, salt: ""))
XCTAssertEqual(expectedDigestString, CryptoHashing.sha256(string: stringToHash, salt: ""))
XCTAssertEqual(expectedDigestString, CryptoHashing.commonCryptoSha256(strData: dataToHash))

// even though we already test if we can import CryptoKit, somehow this still fails on iOS 12,
Expand All @@ -31,9 +31,9 @@ final class CryptoHashingTests: XCTestCase {
let secondSalt = "x21MTSq3MRSmLjVFsYIe"
let expectedSecondDigestString = "acb027bb031c0f73de26c6b8d0441d9c98449d582a538014c44ca49b4c299aa8"

XCTAssertEqual(expectedDigestString, CryptoHashing.sha256(str: stringToHash, salt: salt))
XCTAssertEqual(expectedSecondDigestString, CryptoHashing.sha256(str: stringToHash, salt: secondSalt))
XCTAssertNotEqual(CryptoHashing.sha256(str: stringToHash, salt: salt), CryptoHashing.sha256(str: stringToHash, salt: secondSalt))
XCTAssertEqual(expectedDigestString, CryptoHashing.sha256(string: stringToHash, salt: salt))
XCTAssertEqual(expectedSecondDigestString, CryptoHashing.sha256(string: stringToHash, salt: secondSalt))
XCTAssertNotEqual(CryptoHashing.sha256(string: stringToHash, salt: salt), CryptoHashing.sha256(string: stringToHash, salt: secondSalt))
}
#endif
}

0 comments on commit e64fae3

Please sign in to comment.