Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create #1

Merged
merged 35 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3af116a
feat: Creation
sirewix Jul 4, 2024
3cc225e
test: Implement infrastructure for e2e testing
tlater-famedly Jul 17, 2024
aa1e2de
refactor: Stop using the ldap cache for now
tlater-famedly Jul 17, 2024
c4bf694
style: Remove unnecessary imports in the config module
tlater-famedly Jul 17, 2024
11415e5
chore: Fix yaml editorconfig
tlater-famedly Jul 17, 2024
b0a8ff8
doc: Add basic doc comments across the project
tlater-famedly Jul 17, 2024
59bb88f
feat: Implement Zitadel user creation
tlater-famedly Jul 17, 2024
0fe1e68
tests: Switch to openldap for testing
tlater-famedly Jul 22, 2024
b4da691
fix: Set required ldap attributes
tlater-famedly Jul 22, 2024
3a06467
ci: Update docker workflow
emgrav Jul 23, 2024
f385dac
chore: Update Dockerfile
emgrav Jul 23, 2024
a43dc56
test: Clean up Zitadel org before running the tests
tlater-famedly Jul 23, 2024
12d624f
test: Assert that the Zitadel user is actually created
tlater-famedly Jul 23, 2024
a486686
test: Clean up tests a bit by making a struct for ldap
tlater-famedly Jul 23, 2024
7f05bba
test: Implement further e2e test cases
tlater-famedly Jul 23, 2024
6d615bf
test: Improve test setup logging
tlater-famedly Jul 23, 2024
950ae3e
feat: Implement LDAP sync cache
tlater-famedly Jul 23, 2024
9fa86e6
fix: Don't exit when a single user fails to sync
tlater-famedly Jul 23, 2024
0e76a87
fix: Don't sync disabled users
tlater-famedly Jul 23, 2024
e101c34
refactor: Clean up user conversion to more easily persist metadata
tlater-famedly Jul 24, 2024
ce19cf5
chore: Update to new zitadel-rust-client Zitadel::new()
tlater-famedly Jul 24, 2024
b8d72d8
feat: Add preferred username to user metadata
tlater-famedly Jul 24, 2024
4b54d22
feat: Add user grants
tlater-famedly Jul 25, 2024
1b6d8e5
feat: Add UUID to synced users
tlater-famedly Jul 25, 2024
c108c51
feat: Delete disabled users
tlater-famedly Jul 25, 2024
83c9faf
feat: Implement propagating LDAP user deletion
tlater-famedly Jul 25, 2024
4d6e138
feat: Implement user change sync
tlater-famedly Jul 26, 2024
123845c
test: Assert that email changes are handled correctly
tlater-famedly Jul 26, 2024
feb102e
doc: Document edge cases
tlater-famedly Jul 25, 2024
11ee72d
ci: Fix missing entry to `PATH`
tlater-famedly Jul 26, 2024
df7c116
ci: Don't run everything in a container so we can use docker
tlater-famedly Jul 28, 2024
e75ec51
refactor: Properly represent user fields that aren't static values
tlater-famedly Jul 30, 2024
d4c92f7
doc: Add documentation for testing
tlater-famedly Jul 30, 2024
5673def
style: Give methods proper names
tlater-famedly Jul 30, 2024
8908e8f
feat: Log successful outcomes better
tlater-famedly Jul 30, 2024
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
19 changes: 19 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
experimental = ["setup-scripts"]

[test-groups]
# E2E tests rely on syncing data from ldap; if multiple tests create
# users simultaneously, one thread will "win" and sync its users first
# (or nobody wins and a bunch of tests try to create users that
# already exist) - we don't want this.
e2e = { max-threads = 1 }

[script.start-e2e-env]
command = "./.config/starte2e.sh"

[[profile.default.scripts]]
filter = "test(e2e)"
setup = "start-e2e-env"

[[profile.default.overrides]]
filter = "test(e2e)"
test-group = "e2e"
11 changes: 11 additions & 0 deletions .config/starte2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -eu

# CI does not add /usr/bin to $PATH for some reason, which means we
# lack docker
export PATH="${PATH}:/usr/bin"

# Shut down any still running test-setup first
docker compose --project-directory ./tests/environment down -v test-setup || true
docker compose --project-directory ./tests/environment up --wait
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trim_trailing_whitespace = true
indent_size = 4
indent_style = tab

[*.ya?ml]
[*.y{,a}ml]
indent_style = space
indent_size = 2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
uses: famedly/backend-build-workflows/.github/workflows/docker-backend.yml@main
secrets: inherit
with:
name: project-name
name: famedly-sync-agent
126 changes: 118 additions & 8 deletions .github/workflows/rust-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust
name: Rust workflow

# Trigger the CI on any tags, pushes to any branch and PRs to any branch.
on:
Expand All @@ -8,17 +8,127 @@ on:
pull_request:
branches: [ "*" ]

env:
CARGO_TERM_COLOR: always
ADDITIONAL_PACKAGES: ""

# Make sure there is no pipeline running uselessly.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Environment variables for all jobs.
env:
CARGO_TERM_COLOR: always

# Defined CI jobs.
jobs:
check:
uses: famedly/backend-build-workflows/.github/workflows/rust-workflow.yml@main
secrets: inherit
simple-checks:
container: ghcr.io/famedly/rust-container:nightly
# This is set explictly to allow Meow-Coverage to post comments in response to Dependabot PRs which have a read-only GITHUB_TOKEN by default
permissions:
pull-requests: write
issues: write
contents: read
runs-on: ubuntu-latest-16core
steps:
- name: Checkout current repository
uses: actions/checkout@v3
with:
path: head

- uses: famedly/backend-build-workflows/.github/actions/rust-prepare@main
with:
gitlab_ssh: ${{ secrets.CI_SSH_PRIVATE_KEY}}
gitlab_user: ${{ secrets.GITLAB_USER }}
gitlab_pass: ${{ secrets.GITLAB_PASS }}

- name: Caching
uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191
with:
workspaces: "head -> target"

- name: Rustfmt
shell: bash
working-directory: head
run: cargo +${NIGHTLY_VERSION} fmt -- --check

- name: Clippy
working-directory: head
shell: bash
run: cargo +${NIGHTLY_VERSION} clippy --workspace --all-targets -- -D warnings

- name: Doc-test
shell: bash
working-directory: head
run: cargo +${NIGHTLY_VERSION} test --doc --workspace --verbose

- name: Udeps
shell: bash
working-directory: head
run: cargo +${NIGHTLY_VERSION} udeps

- name: Typos
shell: bash
working-directory: head
run: typos --exclude '*.key' --exclude '*.crt' --exclude '*.csr' --exclude '*.srl'

tests:
runs-on: ubuntu-latest-16core
steps:
- name: Checkout current repository
uses: actions/checkout@v3
with:
path: head

- uses: famedly/backend-build-workflows/.github/actions/rust-prepare@main
with:
gitlab_ssh: ${{ secrets.CI_SSH_PRIVATE_KEY}}
gitlab_user: ${{ secrets.GITLAB_USER }}
gitlab_pass: ${{ secrets.GITLAB_PASS }}

- name: Install additional cargo tooling
shell: bash
run: cargo install cargo-llvm-cov cargo-nextest --locked

emgrav marked this conversation as resolved.
Show resolved Hide resolved
- name: Caching
uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191
with:
workspaces: "head -> target"

- name: Test & Coverage
timeout-minutes: 20
shell: bash
working-directory: head
run: cargo llvm-cov nextest --no-fail-fast --workspace --lcov --output-path $GITHUB_WORKSPACE/new-cov.lcov

- name: Load base coverage results from cache
if: github.event_name == 'pull_request'
id: cache-coverage
uses: actions/cache@v3
with:
path: ./old-cov.lcov
key: coverage-${{ github.event.pull_request.base.sha }}

- name: Pull base
uses: actions/checkout@v3
if: github.event_name == 'pull_request' && steps.cache-coverage.outputs.cache-hit != 'true'
with:
ref: ${{ github.event.pull_request.base.ref }}
repository: ${{ github.event.pull_request.base.full_name }}
path: base

- name: Generate base coverage
if: github.event_name == 'pull_request' && steps.cache-coverage.outputs.cache-hit != 'true'
shell: bash
working-directory: base
run: cargo llvm-cov nextest --workspace --lcov --output-path $GITHUB_WORKSPACE/old-cov.lcov

- name: Meow Coverage
id: coverage-report
uses: famedly/meow-coverage@main
if: github.event_name == 'pull_request'
with:
new-lcov-file: 'new-cov.lcov'
old-lcov-file: ${{ github.event_name == 'pull_request' && 'old-cov.lcov' || '' }}
source-prefix: 'src/'
pr-number: ${{ github.event_name == 'pull_request' && github.event.pull_request.number || '' }}
repo-name: ${{ github.repository }}
commit-id: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.event.after }}
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
/target
config.yaml
/tests/environment/zitadel/service-user.json
/tests/environment/config.yaml
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-byte-order-marker
- id: check-case-conflict
Expand All @@ -13,11 +13,11 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: [email protected]:famedly/backend-pre-commit-templates.git
rev: aa3b2b339abad304b2be3122eb86f4b4df272a6b
rev: 548bf6ae934623c72e2e5f90e095b45259b6f4ba
hooks:
- id: fmt
- id: clippy
- repo: https://github.com/crate-ci/typos
rev: v1.19.0
rev: v1.22.9
hooks:
- id: typos
Loading
Loading