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
14 changes: 14 additions & 0 deletions .github/workflows/VerifyChanges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@ on:
branches: [ $default-branch ]

jobs:
lint:
name: Lint
runs-on: macos-15
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode 16.4
run: |
sudo xcode-select -s /Applications/Xcode_16.4.0.app
- name: Lint
run: |
Scripts/lint
build-and-test:
name: Build and Test (${{ matrix.platform }})
needs: lint
runs-on: macos-15
strategy:
fail-fast: false
Expand Down
75 changes: 75 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"indentConditionalCompilationBlocks": false,
"indentSwitchCaseLabels": false,
"indentation": {
"spaces": 4
},
"lineBreakAroundMultilineExpressionChainComponents": false,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": false,
"lineBreakBeforeEachGenericRequirement": false,
"lineBreakBetweenDeclarationAttributes": false,
"lineLength": 120,
"maximumBlankLines": 2,
"multiElementCollectionTrailingCommas": true,
"noAssignmentInExpressions": {
"allowedFunctions": []
},
"prioritizeKeepingFunctionOutputTogether": true,
"reflowMultilineStringLiterals": {
"never": {}
},
"respectsExistingLineBreaks": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": true,
"AlwaysUseLowerCamelCase": true,
"AmbiguousTrailingClosureOverload": true,
"AvoidRetroactiveConformances": false,
"BeginDocumentationCommentWithOneLineSummary": true,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": true,
"NoAssignmentInExpressions": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyLinesOpeningClosingBraces": false,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoPlaygroundLiterals": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": false,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReplaceForEachWithForLoop": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"TypeNamesShouldBeCapitalized": true,
"UseEarlyExits": true,
"UseExplicitNilCheckInConditions": true,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": true,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": true,
"ValidateDocumentationComments": false
},
"spacesAroundRangeFormationOperators": true,
"spacesBeforeEndOfLineComments": 4,
"tabWidth": 4,
"version": 1
}
1 change: 0 additions & 1 deletion App/Sources/DevKeychainApp/DevKeychainApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import SwiftUI


@main
struct DevKeychainAppApp: App {
var body: some Scene {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import DevTesting
import Foundation
import Testing


#if !os(macOS)
struct GenericPasswordIntegrationTests: RandomValueGenerating {
var randomNumberGenerator = makeRandomNumberGenerator()
Expand All @@ -25,33 +24,33 @@ struct GenericPasswordIntegrationTests: RandomValueGenerating {
}
)
let keychain = Keychain()

// Delete any existing items with the service
let serviceQuery = GenericPassword.Query(service: service)
try keychain.deleteItems(matching: serviceQuery)
#expect(try keychain.items(matching: serviceQuery).isEmpty)

// Add something for each of our accounts
for account in accounts {
let attributes = GenericPassword.AdditionAttributes(
service: service,
account: account,
data: randomData()
)

let addedItem = try keychain.addItem(with: attributes)
#expect(addedItem.service == attributes.service)
#expect(addedItem.account == attributes.account)
#expect(addedItem.data == attributes.data)

let queryResults = try keychain.items(matching: addedItem.query, options: .init(limit: 1))
#expect(queryResults == [addedItem])
}

// Query all items with the service
let allItems = try keychain.items(matching: serviceQuery)
#expect(allItems.count == accounts.count)

// Delete everything
try keychain.deleteItems(matching: serviceQuery)
#expect(try keychain.items(matching: serviceQuery).isEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import DevTesting
import Foundation
import Testing


#if !os(macOS)
struct InternetPasswordIntegrationTests: RandomValueGenerating {
var randomNumberGenerator = makeRandomNumberGenerator()
Expand All @@ -25,33 +24,33 @@ struct InternetPasswordIntegrationTests: RandomValueGenerating {
}
)
let keychain = Keychain()

// Delete any existing items with the server
let serverQuery = InternetPassword.Query(server: server)
try keychain.deleteItems(matching: serverQuery)
#expect(try keychain.items(matching: serverQuery).isEmpty)

// Add something for each of our accounts
for account in accounts {
let attributes = InternetPassword.AdditionAttributes(
server: server,
account: account,
data: randomData()
)

let addedItem = try keychain.addItem(with: attributes)
#expect(addedItem.server == attributes.server)
#expect(addedItem.account == attributes.account)
#expect(addedItem.data == attributes.data)

let queryResults = try keychain.items(matching: addedItem.query, options: .init(limit: 1))
#expect(queryResults == [addedItem])
}

// Query all items with the server
let allItems = try keychain.items(matching: serverQuery)
#expect(allItems.count == accounts.count)

// Delete everything
try keychain.deleteItems(matching: serverQuery)
#expect(try keychain.items(matching: serverQuery).isEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// Created by Prachi Gauriar on 6/22/25.
//

@testable import DevKeychain
import DevTesting
import Foundation
import Testing

@testable import DevKeychain

struct StandardKeychainServicesTests: RandomValueGenerating {
var randomNumberGenerator = makeRandomNumberGenerator()
Expand All @@ -29,7 +29,7 @@ struct StandardKeychainServicesTests: RandomValueGenerating {
let serviceQuery: [CFString: Any] = [
kSecClass: kSecClassGenericPassword,
kSecAttrService: service,
kSecReturnAttributes: true
kSecReturnAttributes: true,
]

try keychainServices.deleteItems(matchingQuery: serviceQuery)
Expand Down Expand Up @@ -80,7 +80,7 @@ struct StandardKeychainServicesTests: RandomValueGenerating {
let object = try keychainServices.items(
matchingQuery: [
kSecClass: kSecClassGenericPassword,
kSecAttrService: randomAlphanumericString(count: 32)
kSecAttrService: randomAlphanumericString(count: 32),
]
)
let items = try #require(object as? [Any])
Expand All @@ -106,7 +106,7 @@ struct StandardKeychainServicesTests: RandomValueGenerating {
try keychainServices.deleteItems(
matchingQuery: [
kSecClass: kSecClassGenericPassword,
kSecAttrService: randomAlphanumericString(count: 32)
kSecAttrService: randomAlphanumericString(count: 32),
]
)
}
Expand Down
Loading
Loading