Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: firebase/firebase-admin-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.7.0
Choose a base ref
...
head repository: firebase/firebase-admin-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 28,943 additions and 2,713 deletions.
  1. +17 −5 ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE/bug_report.md
  2. +20 −0 .github/ISSUE_TEMPLATE/feature_request.md
  3. +6 −0 .github/dependabot.yml
  4. BIN .github/resources/integ-service-account.json.gpg
  5. +79 −0 .github/scripts/generate_changelog.sh
  6. +184 −0 .github/scripts/publish_preflight_check.sh
  7. +25 −0 .github/scripts/run_integration_tests.sh
  8. +47 −0 .github/workflows/ci.yml
  9. +98 −0 .github/workflows/nightly.yml
  10. +141 −0 .github/workflows/release.yml
  11. +7 −2 .gitignore
  12. +14 −0 .opensource/project.json
  13. +0 −13 .travis.yml
  14. +106 −48 CONTRIBUTING.md
  15. +7 −3 README.md
  16. +6 −10 scripts/bash_utils.sh → firebase_admin/__about__.py
  17. +104 −45 firebase_admin/__init__.py
  18. +760 −0 firebase_admin/_auth_client.py
  19. +434 −0 firebase_admin/_auth_providers.py
  20. +483 −0 firebase_admin/_auth_utils.py
  21. +122 −0 firebase_admin/_gapic_utils.py
  22. +50 −7 firebase_admin/_http_client.py
  23. +707 −0 firebase_admin/_messaging_encoder.py
  24. +497 −0 firebase_admin/_messaging_utils.py
  25. +87 −0 firebase_admin/_rfc3339.py
  26. +208 −0 firebase_admin/_sseclient.py
  27. +467 −0 firebase_admin/_token_gen.py
  28. +103 −0 firebase_admin/_user_identifier.py
  29. +520 −0 firebase_admin/_user_import.py
  30. +759 −313 firebase_admin/_user_mgt.py
  31. +230 −4 firebase_admin/_utils.py
  32. +161 −0 firebase_admin/app_check.py
  33. +706 −584 firebase_admin/auth.py
  34. +53 −23 firebase_admin/credentials.py
  35. +326 −154 firebase_admin/db.py
  36. +237 −0 firebase_admin/exceptions.py
  37. +52 −41 firebase_admin/firestore.py
  38. +92 −0 firebase_admin/firestore_async.py
  39. +438 −0 firebase_admin/functions.py
  40. +15 −22 firebase_admin/instance_id.py
  41. +588 −0 firebase_admin/messaging.py
  42. +992 −0 firebase_admin/ml.py
  43. +664 −0 firebase_admin/project_management.py
  44. +764 −0 firebase_admin/remote_config.py
  45. +9 −6 firebase_admin/storage.py
  46. +445 −0 firebase_admin/tenant_mgt.py
  47. +10 −1 integration/conftest.py
  48. +694 −23 integration/test_auth.py
  49. +110 −47 integration/test_db.py
  50. +56 −5 integration/test_firestore.py
  51. +114 −0 integration/test_firestore_async.py
  52. +56 −0 integration/test_functions.py
  53. +5 −3 integration/test_instance_id.py
  54. +222 −0 integration/test_messaging.py
  55. +437 −0 integration/test_ml.py
  56. +182 −0 integration/test_project_management.py
  57. +417 −0 integration/test_tenant_mgt.py
  58. +8 −5 lint.sh
  59. +12 −9 requirements.txt
  60. +0 −102 scripts/prepare_release.sh
  61. +0 −45 scripts/verify_release.sh
  62. +1 −4 setup.cfg
  63. +33 −27 setup.py
  64. 0 snippets/__init__.py
  65. 0 snippets/auth/__init__.py
  66. +29 −0 snippets/auth/get_service_account_tokens.py
  67. +1,105 −0 snippets/auth/index.py
  68. 0 snippets/database/__init__.py
  69. +360 −0 snippets/database/index.py
  70. 0 snippets/firestore/__init__.py
  71. +84 −0 snippets/firestore/firestore.py
  72. +132 −0 snippets/firestore/firestore_async.py
  73. 0 snippets/messaging/__init__.py
  74. +291 −0 snippets/messaging/cloud_messaging.py
  75. +6 −0 tests/data/firebase_config.json
  76. 0 tests/data/firebase_config_empty.json
  77. +1 −0 tests/data/firebase_config_invalid.json
  78. +4 −0 tests/data/firebase_config_invalid_key.json
  79. +4 −0 tests/data/firebase_config_partial.json
  80. +1 −1 tests/data/get_user.json
  81. +1 −0 tests/data/invalid_model.tflite
  82. +18 −0 tests/data/list_oidc_provider_configs.json
  83. +40 −0 tests/data/list_saml_provider_configs.json
  84. +3 −3 tests/data/list_users.json
  85. BIN tests/data/model1.tflite
  86. +7 −0 tests/data/oidc_provider_config.json
  87. +18 −0 tests/data/saml_provider_config.json
  88. +205 −25 tests/test_app.py
  89. +275 −0 tests/test_app_check.py
  90. +0 −864 tests/test_auth.py
  91. +752 −0 tests/test_auth_providers.py
  92. +20 −5 tests/test_credentials.py
  93. +424 −135 tests/test_db.py
  94. +336 −0 tests/test_exceptions.py
  95. +143 −53 tests/test_firestore.py
  96. +167 −0 tests/test_firestore_async.py
  97. +305 −0 tests/test_functions.py
  98. +106 −1 tests/test_http_client.py
  99. +64 −31 tests/test_instance_id.py
  100. +2,684 −0 tests/test_messaging.py
  101. +1,154 −0 tests/test_ml.py
  102. +1,251 −0 tests/test_project_management.py
  103. +984 −0 tests/test_remote_config.py
  104. +67 −0 tests/test_rfc3339.py
  105. +144 −0 tests/test_sseclient.py
  106. +1,017 −0 tests/test_tenant_mgt.py
  107. +857 −0 tests/test_token_gen.py
  108. +1,537 −0 tests/test_user_mgt.py
  109. +160 −9 tests/testutils.py
  110. +0 −35 tox.ini
22 changes: 17 additions & 5 deletions ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
---
name: Bug report
about: Bug reports related to any component in this repo
title: ''
labels: ''
assignees: ''

---

### [READ] Step 1: Are you in the right place?

* For issues or feature requests related to __the code in this repository__
file a Github issue.
* If this is a __feature request__ make sure the issue title starts with "FR:".
* For issues related to __the code in this repository__ file a GitHub issue.
* If the issue pertains to __Cloud Firestore__, report directly in the
[Python Firestore](https://github.com/googleapis/python-firestore) GitHub repo. Firestore
bugs reported in this repo will be closed with a reference to the Python Firestore
project.
* For general technical questions, post a question on [StackOverflow](http://stackoverflow.com/)
with the firebase tag.
with the `firebase` tag.
* For general Firebase discussion, use the [firebase-talk](https://groups.google.com/forum/#!forum/firebase-talk)
google group.
* For help troubleshooting your application that does not fall under one
@@ -15,8 +26,9 @@

* Operating System version: _____
* Firebase SDK version: _____
* Library version: _____
* Firebase Product: _____ (auth, database, storage, etc)
* Python version: _____
* Pip version: _____

### [REQUIRED] Step 3: Describe the problem

20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FR]"
labels: 'type: feature request'
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context, code samples or screenshots about the feature request here.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
Binary file added .github/resources/integ-service-account.json.gpg
Binary file not shown.
79 changes: 79 additions & 0 deletions .github/scripts/generate_changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

# Copyright 2020 Google Inc.
#
# 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.

set -e
set -u

function printChangelog() {
local TITLE=$1
shift
# Skip the sentinel value.
local ENTRIES=("${@:2}")
if [ ${#ENTRIES[@]} -ne 0 ]; then
echo "### ${TITLE}"
echo ""
for ((i = 0; i < ${#ENTRIES[@]}; i++))
do
echo "* ${ENTRIES[$i]}"
done
echo ""
fi
}

if [[ -z "${GITHUB_SHA}" ]]; then
GITHUB_SHA="HEAD"
fi

LAST_TAG=`git describe --tags $(git rev-list --tags --max-count=1) 2> /dev/null` || true
if [[ -z "${LAST_TAG}" ]]; then
echo "[INFO] No tags found. Including all commits up to ${GITHUB_SHA}."
VERSION_RANGE="${GITHUB_SHA}"
else
echo "[INFO] Last release tag: ${LAST_TAG}."
COMMIT_SHA=`git show-ref -s ${LAST_TAG}`
echo "[INFO] Last release commit: ${COMMIT_SHA}."
VERSION_RANGE="${COMMIT_SHA}..${GITHUB_SHA}"
echo "[INFO] Including all commits in the range ${VERSION_RANGE}."
fi

echo ""

# Older versions of Bash (< 4.4) treat empty arrays as unbound variables, which triggers
# errors when referencing them. Therefore we initialize each of these arrays with an empty
# sentinel value, and later skip them.
CHANGES=("")
FIXES=("")
FEATS=("")
MISC=("")

while read -r line
do
COMMIT_MSG=`echo ${line} | cut -d ' ' -f 2-`
if [[ $COMMIT_MSG =~ ^change(\(.*\))?: ]]; then
CHANGES+=("$COMMIT_MSG")
elif [[ $COMMIT_MSG =~ ^fix(\(.*\))?: ]]; then
FIXES+=("$COMMIT_MSG")
elif [[ $COMMIT_MSG =~ ^feat(\(.*\))?: ]]; then
FEATS+=("$COMMIT_MSG")
else
MISC+=("${COMMIT_MSG}")
fi
done < <(git log ${VERSION_RANGE} --oneline)

printChangelog "Breaking Changes" "${CHANGES[@]}"
printChangelog "New Features" "${FEATS[@]}"
printChangelog "Bug Fixes" "${FIXES[@]}"
printChangelog "Miscellaneous" "${MISC[@]}"
184 changes: 184 additions & 0 deletions .github/scripts/publish_preflight_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
#!/bin/bash

# Copyright 2020 Google Inc.
#
# 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.


###################################### Outputs #####################################

# 1. version: The version of this release including the 'v' prefix (e.g. v1.2.3).
# 2. changelog: Formatted changelog text for this release.

####################################################################################

set -e
set -u

function echo_info() {
local MESSAGE=$1
echo "[INFO] ${MESSAGE}"
}

function echo_warn() {
local MESSAGE=$1
echo "[WARN] ${MESSAGE}"
}

function terminate() {
echo ""
echo_warn "--------------------------------------------"
echo_warn "PREFLIGHT FAILED"
echo_warn "--------------------------------------------"
exit 1
}


echo_info "Starting publish preflight check..."
echo_info "Git revision : ${GITHUB_SHA}"
echo_info "Workflow triggered by : ${GITHUB_ACTOR}"
echo_info "GitHub event : ${GITHUB_EVENT_NAME}"


echo_info ""
echo_info "--------------------------------------------"
echo_info "Extracting release version"
echo_info "--------------------------------------------"
echo_info ""

readonly ABOUT_FILE="firebase_admin/__about__.py"
echo_info "Loading version from: ${ABOUT_FILE}"

readonly RELEASE_VERSION=`grep "__version__" ${ABOUT_FILE} | awk '{print $3}' | tr -d \'` || true
if [[ -z "${RELEASE_VERSION}" ]]; then
echo_warn "Failed to extract release version from: ${ABOUT_FILE}"
terminate
fi

if [[ ! "${RELEASE_VERSION}" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
echo_warn "Malformed release version string: ${RELEASE_VERSION}. Exiting."
terminate
fi

echo_info "Extracted release version: ${RELEASE_VERSION}"
echo "version=v${RELEASE_VERSION}" >> $GITHUB_OUTPUT


echo_info ""
echo_info "--------------------------------------------"
echo_info "Check release artifacts"
echo_info "--------------------------------------------"
echo_info ""

if [[ ! -d dist ]]; then
echo_warn "dist directory does not exist."
terminate
fi

readonly BIN_DIST="dist/firebase_admin-${RELEASE_VERSION}-py3-none-any.whl"
if [[ -f "${BIN_DIST}" ]]; then
echo_info "Found binary distribution (bdist_wheel): ${BIN_DIST}"
else
echo_warn "Binary distribution ${BIN_DIST} not found."
terminate
fi

readonly SRC_DIST="dist/firebase_admin-${RELEASE_VERSION}.tar.gz"
if [[ -f "${SRC_DIST}" ]]; then
echo_info "Found source distribution (sdist): ${SRC_DIST}"
else
echo_warn "Source distribution ${SRC_DIST} not found."
terminate
fi

readonly ARTIFACT_COUNT=`ls dist/ | wc -l`
if [[ $ARTIFACT_COUNT -ne 2 ]]; then
echo_warn "Unexpected artifacts in the distribution directory."
ls -l dist
terminate
fi


echo_info ""
echo_info "--------------------------------------------"
echo_info "Checking previous releases"
echo_info "--------------------------------------------"
echo_info ""

readonly PYPI_URL="https://pypi.org/pypi/firebase-admin/${RELEASE_VERSION}/json"
readonly PYPI_STATUS=`curl -s -o /dev/null -L -w "%{http_code}" ${PYPI_URL}`
if [[ $PYPI_STATUS -eq 404 ]]; then
echo_info "Release version ${RELEASE_VERSION} not found in Pypi."
elif [[ $PYPI_STATUS -eq 200 ]]; then
echo_warn "Release version ${RELEASE_VERSION} already present in Pypi."
terminate
else
echo_warn "Unexpected ${PYPI_STATUS} response from Pypi. Exiting."
terminate
fi


echo_info ""
echo_info "--------------------------------------------"
echo_info "Checking release tag"
echo_info "--------------------------------------------"
echo_info ""

echo_info "---< git fetch --depth=1 origin +refs/tags/*:refs/tags/* >---"
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
echo ""

readonly EXISTING_TAG=`git rev-parse -q --verify "refs/tags/v${RELEASE_VERSION}"` || true
if [[ -n "${EXISTING_TAG}" ]]; then
echo_warn "Tag v${RELEASE_VERSION} already exists. Exiting."
echo_warn "If the tag was created in a previous unsuccessful attempt, delete it and try again."
echo_warn " $ git tag -d v${RELEASE_VERSION}"
echo_warn " $ git push --delete origin v${RELEASE_VERSION}"

readonly RELEASE_URL="https://github.com/firebase/firebase-admin-python/releases/tag/v${RELEASE_VERSION}"
echo_warn "Delete any corresponding releases at ${RELEASE_URL}."
terminate
fi

echo_info "Tag v${RELEASE_VERSION} does not exist."


echo_info ""
echo_info "--------------------------------------------"
echo_info "Generating changelog"
echo_info "--------------------------------------------"
echo_info ""

echo_info "---< git fetch origin master --prune --unshallow >---"
git fetch origin master --prune --unshallow
echo ""

echo_info "Generating changelog from history..."
readonly CURRENT_DIR=$(dirname "$0")
readonly CHANGELOG=`${CURRENT_DIR}/generate_changelog.sh`
echo "$CHANGELOG"

# Parse and preformat the text to handle multi-line output.
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
# and https://github.com/github/docs/issues/21529#issue-1418590935
FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "\\[INFO\\]"`
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\''/'"'}"
echo "changelog<<CHANGELOGEOF" >> $GITHUB_OUTPUT
echo -e "$FILTERED_CHANGELOG" >> $GITHUB_OUTPUT
echo "CHANGELOGEOF" >> $GITHUB_OUTPUT


echo ""
echo_info "--------------------------------------------"
echo_info "PREFLIGHT SUCCESSFUL"
echo_info "--------------------------------------------"
25 changes: 25 additions & 0 deletions .github/scripts/run_integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Copyright 2020 Google Inc.
#
# 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.

set -e
set -u

gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}" \
--output integ-service-account.json .github/resources/integ-service-account.json.gpg

echo "${FIREBASE_API_KEY}" > integ-api-key.txt

pytest integration/ --cert integ-service-account.json --apikey integ-api-key.txt
Loading