Skip to content

Commit 19d6f5c

Browse files
authored
feat(auth): Firebase auth repo adapter for auth-user CRUD operations. (#2)
* feat(wip): add firebase integration, auth_service * setup http authorizor * dive into testing ...and touch a bunch of other stuff :\ * wip firebase auth integration tests are starting to work with the emulator * repos share tests, add router test * fix(ci): only run unit tests until an env is setup. * fix(ci): only run unit tests until an env is setup.
1 parent ef4ad48 commit 19d6f5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1943
-334
lines changed

.devcontainer/.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# This file is used by ./docker-compose.yml.
22

3+
TIME_ZONE=US/Eastern # Shell environment
4+
GITHUB_TOKEN= # GitHub CLI
5+
36
# Host ports
47
#
58
# For avoiding conflicts on the host machine.
@@ -16,3 +19,8 @@ HOST_NEO4J_BROWSER_PORT=7474
1619
STRIPE_PUBLIC_KEY=pk_test_ # From Stripe dashboard
1720
STRIPE_SECRET_KEY=sk_test_ # From Stripe dashboard
1821
STRIPE_WEBHOOK_SECRET=whsec_ # From Stripe CLI
22+
23+
# Firebase config
24+
FIREBASE_PROJECT_ID=api-python # Any project ID will work locally, but cannot be blank.
25+
HOST_FIREBASE_AUTH_EMULATOR_PORT=9099
26+
HOST_FIREBASE_EMULATOR_UI_PORT=4000

.devcontainer/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ RUN VERSION=$(basename $(curl -Ls -o /dev/null -w %{url_effective} https://githu
1414
unzip -jo nmig.zip "*/completion/neo4j-migrations_completion" -d ~/.local/share/bash-completion/completions/ && \
1515
mv ~/.local/share/bash-completion/completions/neo4j-migrations_completion ~/.local/share/bash-completion/completions/neo4j-migrations && \
1616
rm nmig.zip
17+
18+
# Install firebase-tools (The npm installer on https://containers.dev/features is extremely slow)
19+
RUN curl -sL https://firebase.tools | bash

.devcontainer/docker-compose.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ services:
77
- ${HOST_API_DEV_PORT}:8000
88
- ${HOST_API_DOCKER_PORT}:8001
99
- ${HOST_API_SAM_PORT}:8002
10+
- ${HOST_FIREBASE_AUTH_EMULATOR_PORT}:9099
11+
- ${HOST_FIREBASE_EMULATOR_UI_PORT}:4000
1012
command: sleep infinity
1113
depends_on:
1214
- postgres
1315
- neo4j
1416
volumes:
1517
- ..:/api-python:cached
1618
environment:
17-
# From host machine
18-
TZ: ${TZ} # Timezone
19-
GITHUB_TOKEN: ${GITHUB_TOKEN} # Github CLI
19+
TZ: ${TIME_ZONE}
20+
GITHUB_TOKEN: ${GITHUB_TOKEN}
2021
# Python
2122
LOGGING_LEVEL: DEBUG
2223
# Postgres
@@ -28,6 +29,10 @@ services:
2829
STRIPE_PUBLIC_KEY: ${STRIPE_PUBLIC_KEY}
2930
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
3031
STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET}
32+
# Firebase
33+
FIREBASE_PROJECT_ID: ${FIREBASE_PROJECT_ID}
34+
FIREBASE_AUTH_EMULATOR_HOST: localhost:9099
35+
VERIFY_TOKEN_SIGNATURE: 0
3136

3237
postgres:
3338
image: postgres

.devcontainer/host-init.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env bash
22

33
# Copy .env.example to .env if necessary.
4-
if [ ! -f ".env" ]; then
5-
cp .env.example .env
6-
fi
74
if [ ! -f ".devcontainer/.env" ]; then
85
cp .devcontainer/.env.example .devcontainer/.env
96
fi
7+
if [ ! -f "scripts/admin/.env" ]; then
8+
cp scripts/admin/.env.example scripts/admin/.env
9+
fi
10+

.devcontainer/post-create.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ ln -s "$(pwd)/.devcontainer/.bash_history" ~/.bash_history
66
# Install the user's dotfiles from GitHub.
77
gh repo clone dotfiles ~/.dotfiles && ~/.dotfiles/install.sh
88

9-
# Copy .env.example to .env if necessary.
10-
if [ ! -f ".env" ]; then
11-
cp .env.example .env
12-
fi
13-
if [ ! -f ".devcontainer/.env" ]; then
14-
cp .devcontainer/.env.example .devcontainer/.env
15-
fi
16-
179
# Create a virtual environment for the project if one doesn't exist.
1810
if [ ! -d ".venv" ]; then
1911
python3 -m venv .venv
@@ -24,5 +16,5 @@ echo "source \"$(pwd)/.venv/bin/activate\"" >> ~/.bashrc
2416

2517
# Add bash completion for the Stripe CLI.
2618
mkdir -p ~/.local/share/bash-completion/completions && \
27-
stripe completion --shell bash && \
19+
stripe completion --shell bash > /dev/null && \
2820
mv stripe-completion.bash ~/.local/share/bash-completion/completions/stripe

.devcontainer/post-start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# Make sure containerd and dockerd are running.
44
sudo nohup containerd &
5-
sudo nohup dockerd &
5+
sudo nohup dockerd &

.github/workflows/deploy_lambda.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ jobs:
2626
pip install poetry
2727
poetry install --no-interaction
2828
- name: Run tests
29-
run: poetry run pytest
29+
env:
30+
VERIFY_TOKEN_SIGNATURE: 0
31+
run: ./scripts/test.sh unit
3032

3133
- uses: aws-actions/configure-aws-credentials@v4
3234
with:

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- "app/**"
1414
- ".github/workflows/test.yml"
1515
jobs:
16-
cargo-test:
16+
test:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4
@@ -24,4 +24,6 @@ jobs:
2424
pip install poetry
2525
poetry install --no-interaction
2626
- name: Run tests
27-
run: poetry run pytest
27+
env:
28+
VERIFY_TOKEN_SIGNATURE: 0
29+
run: ./scripts/test.sh unit

.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ __pycache__
44
.venv
55
.bash_history
66
.Trash-*
7-
.env
8-
.env.*
9-
!.env.example
7+
**/.env
8+
**/.env.*
9+
!**/.env.example
1010
.aws-sam
11-
Pipfile*
11+
Pipfile*
12+
firebase_emulator_data
13+
firebase-debug.log

.vscode/settings.json

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,28 @@
2929
"commands": [
3030
"./scripts/run.sh"
3131
]
32+
}
33+
]
34+
},
35+
{
36+
"splitTerminals": [
37+
{
38+
"name": "test unit",
39+
"commands": [
40+
"./scripts/test.sh unit"
41+
]
42+
},
43+
{
44+
"name": "test integration",
45+
"commands": [
46+
"./scripts/test.sh integration"
47+
]
48+
},
49+
{
50+
"name": "test e2e",
51+
"commands": [
52+
"./scripts/test.sh e2e"
53+
]
3254
},
3355
]
3456
},
@@ -51,11 +73,11 @@
5173
{
5274
"splitTerminals": [
5375
{
54-
"name": "stripe",
76+
"name": "stripe :8000",
5577
"commands": [
56-
"./scripts/stripe-listen.sh"
78+
"./scripts/stripe-listen.sh 8000"
5779
]
58-
},
80+
}
5981
]
6082
},
6183
{
@@ -88,6 +110,8 @@
88110
"!Join sequence"
89111
],
90112
"python.testing.pytestArgs": [
91-
"tests"
113+
"."
92114
],
115+
"python.testing.unittestEnabled": false,
116+
"python.testing.pytestEnabled": true,
93117
}

0 commit comments

Comments
 (0)