diff --git a/Cargo.lock b/Cargo.lock index 3bc664f..1838344 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -984,7 +984,7 @@ dependencies = [ [[package]] name = "vaultwarden_ldap" -version = "0.6.2" +version = "1.0.0" dependencies = [ "anyhow", "envy", diff --git a/Cargo.toml b/Cargo.toml index e361f35..7de867e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vaultwarden_ldap" -version = "0.6.2" +version = "1.0.0" authors = ["ViViDboarder "] edition = "2018" diff --git a/Makefile b/Makefile index 24dea5f..4be376b 100644 --- a/Makefile +++ b/Makefile @@ -38,14 +38,28 @@ test: itest: docker-compose -f docker-compose.yml \ -f itest/docker-compose.itest.yml \ - up --build + build + docker-compose -f docker-compose.yml \ + -f itest/docker-compose.itest.yml \ + up -d vaultwarden ldap + docker-compose -f docker-compose.yml \ + -f itest/docker-compose.itest.yml \ + run ldap_sync + docker-compose stop # Run bootstrapped integration test using env for config .PHONY: itest-env itest-env: docker-compose -f docker-compose.yml \ -f itest/docker-compose.itest-env.yml \ - up --build + build + docker-compose -f docker-compose.yml \ + -f itest/docker-compose.itest-env.yml \ + up -d vaultwarden ldap + docker-compose -f docker-compose.yml \ + -f itest/docker-compose.itest-env.yml \ + run ldap_sync + docker-compose stop .PHONY: clean-itest clean-itest: diff --git a/README.md b/README.md index b06b626..9c0f14f 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,18 @@ For those less familiar with `cargo`, you can use the `make` targets that have b ## Testing -All testing is manual right now. First step is to set up Bitwarden and the LDAP server. +There are no unit tests, but there are integration tests that require manual verification. + +### Integration tests + +Running `make itest` will spin up an ldap server with a test user, a Vaultwarden server, and then run the sync. If successful the log should show an invitation sent to the test user. If you run `make itest` again, it should show no invites sent because the user already has been invited. If you'd like to reset the testing, `make clean-itest` will clear out the Vaultwarden database and start fresh. + +It's also possible to test passing configs via enviornment variables by running `make itest-env`. The validation steps are the same. + + +### Steps for manual testing + +The first step is to set up Bitwarden and the LDAP server. ```bash docker-compose up -d vaultwarden ldap ldap_admin @@ -74,8 +85,3 @@ docker-compose up ldap_sync Alternately, you can bootstrap some of this by running: docker-compose -f docker-compose.yml -f itest/docker-compose.itest.yml up --build - -## Future - -* Any kind of proper logging -* Tests diff --git a/docker-compose.yml b/docker-compose.yml index ddd6b7c..62afcb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,6 +24,7 @@ services: ADMIN_TOKEN: admin SIGNUPS_ALLOWED: 'false' INVITATIONS_ALLOWED: 'true' + I_REALLY_WANT_VOLATILE_STORAGE: 'true' ldap: image: osixia/openldap diff --git a/itest/docker-compose.itest-env.yml b/itest/docker-compose.itest-env.yml index b09e89c..d0181fb 100644 --- a/itest/docker-compose.itest-env.yml +++ b/itest/docker-compose.itest-env.yml @@ -11,7 +11,7 @@ services: APP_LDAP_BIND_PASSWORD: "admin" APP_LDAP_SEARCH_BASE_DN: "dc=example,dc=org" APP_LDAP_SEARCH_FILTER: "(&(objectClass=*)(uid=*))" - APP_LDAP_SYNC_INTERVAL_SECONDS: 10 + APP_LDAP_SYNC_LOOP: "false" vaultwarden: diff --git a/itest/docker-compose.itest.yml b/itest/docker-compose.itest.yml index e31753c..39adc5f 100644 --- a/itest/docker-compose.itest.yml +++ b/itest/docker-compose.itest.yml @@ -2,6 +2,8 @@ version: '3' services: ldap_sync: + volumes: + - ./itest/config.toml:/config.toml:ro vaultwarden: