Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
32 changes: 32 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,35 @@ jobs:
-destination 'platform=iOS Simulator,name=iPhone 11' \
EMAIL_SECRET=$EMAIL_SECRET \
PASSWORD_SECRET=$PASSWORD_SECRET

app-check-api-token-tests:
runs-on: macOS-12
# Don't run if triggered by a PR from a fork since our Secrets won't be provided to the runner.
if: "!github.event.pull_request.head.repo.fork"
defaults:
run:
working-directory: Samples/Swift/AppAttestExample
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build test target for App Check Example
run: |
xcodebuild \
-project AppAttestExample.xcodeproj \
build-for-testing \
-scheme AppAttestExample \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 11'
- name: Run test target for App Check Example
env:
AppCheckDebugToken : ${{ secrets.APP_CHECK_DEBUG_TOKEN }}
APP_CHECK_WEB_API_KEY : ${{ secrets.APP_CHECK_WEB_API_KEY }}
run: |
xcodebuild \
-project AppAttestExample.xcodeproj \
test-without-building \
-scheme AppAttestExample \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 11' \
AppCheckDebugToken=$AppCheckDebugToken \
APP_CHECK_WEB_API_KEY=$APP_CHECK_WEB_API_KEY
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ Podfile.lock

# Firebase App Check Example
**/GoogleService-Info.plist
**/AppCheckSecrets.xcconfig
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let package = Package(
.package(
name: "AppCheck",
url: "https://github.com/google/app-check.git",
.branch("CocoaPods-0.1.0-alpha.6")),
.branch("CocoaPods-0.1.0-alpha.9")),
.package(
name: "GTMAppAuth",
url: "https://github.com/google/GTMAppAuth.git",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,26 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:AppAttestExample.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "73080B272AAF9BDE00DEF667"
BuildableName = "AppAttestExampleTests.xctest"
BlueprintName = "AppAttestExampleTests"
ReferencedContainer = "container:AppAttestExample.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand Down
40 changes: 40 additions & 0 deletions Samples/Swift/AppAttestExample/AppAttestExample.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"configurations" : [
{
"id" : "BE893D88-5ECF-4AF1-95E1-CE186B02A525",
"name" : "Test Scheme Action",
"options" : {

}
}
],
"defaultOptions" : {
"codeCoverage" : false,
"environmentVariableEntries" : [
{
"key" : "AppCheckDebugToken",
"value" : "$(AppCheckDebugToken)"
},
{
"key" : "APP_CHECK_WEB_API_KEY",
"value" : "$(APP_CHECK_WEB_API_KEY)"
}
],
"targetForVariableExpansion" : {
"containerPath" : "container:AppAttestExample.xcodeproj",
"identifier" : "73080B272AAF9BDE00DEF667",
"name" : "AppAttestExampleTests"
}
},
"testTargets" : [
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:AppAttestExample.xcodeproj",
"identifier" : "73080B272AAF9BDE00DEF667",
"name" : "AppAttestExampleTests"
}
}
],
"version" : 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@ import Foundation

struct AppCheckSecretReader {
private let APIKeyName = "APP_CHECK_WEB_API_KEY"
private let APIKeyResourceName = "AppCheckSecrets"
private let APIKeyExtensionName = "json"
private let debugTokenName = "AppCheckDebugToken"

/// Method to read the App Check debug token from the environment
var debugToken: String? {
guard let debugToken = ProcessInfo.processInfo.environment[debugTokenName],
!debugToken.isEmpty else {
print("Failed to get \(debugTokenName) from environment.")
return nil
}
return debugToken
}

/// Method to read the App Check API key from either the bundle or the environment
var APIKey: String? {
return APIKeyFromBundle ?? APIKeyFromEnvironment
}
Expand All @@ -34,9 +48,9 @@ struct AppCheckSecretReader {

/// Method for retrieving API key from the bundle during simulator or debug builds
private var APIKeyFromBundle: String? {
guard let APIKey = Bundle.main.infoDictionary?[APIKeyName] as? String,
guard let APIKey = Bundle.main.object(forInfoDictionaryKey: APIKeyName) as? String,
!APIKey.isEmpty else {
print("Failed to get \(APIKeyName) from Bundle.")
print("Failed to get \(APIKeyName) from environment.")
return nil
}
return APIKey
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Copyright 2023 Google LLC
//
// 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.

APP_CHECK_WEB_API_KEY=
Loading