Skip to content

Commit 9a3bcfd

Browse files
Configure test keychain for macOS tests (#8494)
* Configure test keychain for macOS tests * Check if the tests fail without the test keychain * Disable unrelated tests temporary * fix platform * fix * Test app check * Apply fix to FCM and App Check * Fix FCM GHA * Line break * Set test keychain as login keychain * Typo * Revert setting login keychain * Disable keychain auto-locking
1 parent c02769d commit 9a3bcfd

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

.github/workflows/app_check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
- uses: actions/checkout@v2
2020
- name: Setup Bundler
2121
run: scripts/setup_bundler.sh
22+
- name: Configure test keychain
23+
run: scripts/configure_test_keychain.sh
2224
- name: FirebaseAppCheck
2325
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseAppCheck.podspec --platforms=${{ matrix.target }}
2426

.github/workflows/messaging.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
runs-on: macos-latest
2828
steps:
2929
- uses: actions/checkout@v2
30+
- name: Configure test keychain
31+
run: scripts/configure_test_keychain.sh
3032
- name: Setup Bundler
3133
run: scripts/setup_bundler.sh
3234
- name: Install Secret GoogleService-Info.plist

scripts/configure_test_keychain.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2021 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -euo pipefail
18+
set -o xtrace
19+
20+
TEST_KEYCHAIN_NAME="temp.keychain"
21+
TEST_KEYCHAIN_PASSWORD="temp.keychain.password"
22+
23+
# Print list of existing keychains.
24+
security list-keychains
25+
26+
# Print current default keychain.
27+
security default-keychain
28+
29+
# Remove test keychain form previous runs if exists.
30+
if security delete-keychain "$TEST_KEYCHAIN_NAME"; then
31+
echo "Old test keychain was removed."
32+
else
33+
echo "All good, no old test keychain found."
34+
fi
35+
36+
# Create a test keychain.
37+
security create-keychain -p "$TEST_KEYCHAIN_PASSWORD" "$TEST_KEYCHAIN_NAME"
38+
39+
# Disable auto-locking.
40+
security set-keychain-settings "$TEST_KEYCHAIN_NAME"
41+
42+
# Unlock the test keychain.
43+
security unlock-keychain -p "$TEST_KEYCHAIN_PASSWORD" "$TEST_KEYCHAIN_NAME"
44+
45+
# Set the test keychain as default to be used during macOS tests.
46+
security default-keychain -s "$TEST_KEYCHAIN_NAME"

0 commit comments

Comments
 (0)