├── .gitattributes ├── .github └── workflows │ ├── ci.yml │ └── deploy-release.yml ├── .gitignore ├── .pre-commit-config.yaml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── pyproject.toml ├── src └── vaultwarden │ ├── __init__.py │ ├── __version__.py │ ├── clients │ ├── __init__.py │ ├── bitwarden.py │ └── vaultwarden.py │ ├── models │ ├── __init__.py │ ├── bitwarden.py │ ├── enum.py │ ├── exception_models.py │ ├── permissive_model.py │ └── sync.py │ └── utils │ ├── __init__.py │ ├── crypto.py │ ├── logger.py │ └── string_cases.py └── tests ├── __init__.py ├── e2e ├── __init__.py ├── run_tests.sh ├── test_bitwarden.py └── test_vaultwarden.py ├── fixtures ├── admin │ ├── users_camel.json │ └── users_pascal.json ├── server │ ├── db.sqlite3 │ └── rsa_key.pem ├── test-account-2 │ ├── organization_profile_camel.json │ ├── profile_camel.json │ └── sync_camel.json ├── test-account │ ├── sync_camel.json │ └── sync_pascal.json └── test-organization │ ├── collections │ ├── collections_camel.json │ ├── collections_pascal.json │ ├── test-collection-2 │ │ ├── details_camel.json │ │ └── users_camel.json │ └── test-collection │ │ ├── details_camel.json │ │ └── users_camel.json │ ├── organization_camel.json │ ├── organization_pascal.json │ └── users_camel.json ├── models ├── __init__.py └── validation │ ├── __init__.py │ ├── test_bitwarden_models.py │ ├── test_pascal_camel_cases.py │ ├── test_sync_models.py │ └── test_vaultwarden_models.py └── utils └── __init__.py /.gitattributes: -------------------------------------------------------------------------------- 1 | tests/fixtures/server/db.sqlite3 filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | test: 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | python-version: [ '3.10', '3.11', '3.12', '3.13' ] 17 | os: [ ubuntu-latest ] 18 | vaultwarden-version: [ '1.30.5', '1.31.0' , '1.32.7', '1.33.2' ] 19 | runs-on: ${{ matrix.os }} 20 | steps: 21 | - uses: actions/checkout@v3 22 | with: 23 | lfs: true 24 | - name: Setup Python ${{ matrix.python-version }} 25 | uses: actions/setup-python@v4 26 | with: 27 | python-version: ${{ matrix.python-version }} 28 | - name: Install dependencies 29 | run: | 30 | python -m pip install --upgrade hatch 31 | - name: Run Vaultwarden server 32 | run: | 33 | temp_dir=$(mktemp -d) 34 | cp ${{ github.workspace }}/tests/fixtures/server/* $temp_dir 35 | docker run -d --name vaultwarden -v $temp_dir:/data --env I_REALLY_WANT_VOLATILE_STORAGE=true --env ADMIN_TOKEN=admin --restart unless-stopped -p 80:80 vaultwarden/server:${{ matrix.vaultwarden-version }} 36 | - name: Run tests 37 | run: | 38 | hatch run +py=${{ matrix.py || matrix.python-version }} test:with-coverage 39 | env: 40 | VAULTWARDEN_URL: "http://127.0.0.1:80" 41 | VAULTWARDEN_ADMIN_TOKEN: "admin" 42 | BITWARDEN_URL: "http://127.0.0.1:80" 43 | BITWARDEN_EMAIL: "test-account@example.com" 44 | BITWARDEN_PASSWORD: "test-account" 45 | BITWARDEN_CLIENT_ID: "user.a8be340c-856b-481f-8183-2b7712995da2" 46 | BITWARDEN_CLIENT_SECRET: "ag66paVUq4h7tBLbCbJOY5tJkQvUuT" 47 | BITWARDEN_TEST_ORGANIZATION: "cda840d2-1de0-4f31-bd49-b30dacd7e8b0" 48 | BITWARDEN_DEVICE_ID: "e54ba5f5-7d58-4830-8f2b-99194c70c14f" 49 | 50 | lint: 51 | runs-on: ubuntu-latest 52 | steps: 53 | - uses: actions/checkout@v3 54 | - name: Setup Python 55 | uses: actions/setup-python@v4 56 | with: 57 | python-version: '3.13' 58 | - name: Install Python dependencies 59 | run: | 60 | python -m pip install --upgrade hatch 61 | - name: Check with black + isort 62 | if: always() 63 | run: hatch run style:format && git diff --exit-code 64 | - name: Check with ruff 65 | if: always() 66 | run: hatch run style:lint 67 | - name: Check with mypy 68 | if: always() 69 | run: hatch run types:check 70 | 71 | package: 72 | runs-on: ubuntu-latest 73 | steps: 74 | - uses: actions/checkout@v3 75 | - name: Setup Python 76 | uses: actions/setup-python@v4 77 | with: 78 | python-version: '3.10' 79 | - name: Install Hatch 80 | run: | 81 | python -m pip install -U hatch 82 | - name: Build package 83 | run: | 84 | hatch build -------------------------------------------------------------------------------- /.github/workflows/deploy-release.yml: -------------------------------------------------------------------------------- 1 | name: deploy-release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | pypi: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - name: Setup Python 14 | uses: actions/setup-python@v4 15 | with: 16 | python-version: '3.10' 17 | - name: Install Hatch 18 | run: | 19 | python -m pip install -U hatch 20 | - name: Build package 21 | run: | 22 | hatch build 23 | - name: Publish 24 | run: | 25 | hatch publish 26 | env: 27 | HATCH_INDEX_USER: __token__ 28 | HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | default_language_version: 2 | python: python3.11 3 | 4 | repos: 5 | - repo: https://github.com/pre-commit/pre-commit-hooks 6 | rev: v4.4.0 7 | hooks: 8 | - id: trailing-whitespace 9 | - id: check-merge-conflict 10 | 11 | - repo: https://github.com/psf/black 12 | rev: 23.7.0 13 | hooks: 14 | - id: black 15 | 16 | - repo: https://github.com/commitizen-tools/commitizen 17 | rev: v3.5.3 18 | hooks: 19 | - id: commitizen 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.2 (2025-05-21) 2 | 3 | ### Fix 4 | 5 | - **api-fields**: fix api fields for vaultwarden v1.33.x 6 | 7 | ## 1.0.1 (2024-09-25) 8 | 9 | ### Feat 10 | 11 | - **tests**: add tests run to CI 12 | - **tests**: add models tests and e2e tests 13 | - **tests**: add fixtures 14 | 15 | ### Fix 16 | 17 | - **lint**: fix mypy typing 18 | - **org-invite**: fix organization invitte payload 19 | - **cipher-collections**: fix method changing collections of a cipher 20 | - **sync-seat-null**: Seats value can be null 21 | - **lint**: import fix 22 | - **lint**: remove unused import 23 | - **bitwarden**: fix List model and refresh master_ke when refresh token 24 | - **typing**: fix mypy tiping and checks 25 | - **default-values**: remove mutable default values 26 | - **camelcase-api-field**: Allow parsing of API result with camel-cased field follow vaultwarden 1.31 changes 27 | - **typing**: remove 'Optional' typing 28 | - **ci**: trigger CI only when targeting main brancha 29 | 30 | ## 1.0.0 (2024-02-01) 31 | 32 | ### Feat 33 | 34 | - **pydantic**: Rework Bitwarden Client with pydantic classes + Usage 35 | 36 | ## 0.7.0 (2023-09-06) 37 | 38 | ### Feat 39 | 40 | - **init**: first version open-sourced 41 | 42 | ### Fix 43 | 44 | - **license**: fix license property and license classifier = fix typo 45 | - **tests**: fix unit tests 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python-vaultwarden 2 | 3 | [![PyPI Version][pypi-v-image]][pypi-v-link] 4 | [![Build Status][GHAction-image]][GHAction-link] 5 | 6 | A python client library for [vaultwarden](https://github.com/dani-garcia/vaultwarden). 7 | 8 | ## Rationale 9 | 10 | While there are numerous [clients for bitwarden](https://bitwarden.com/download/), its low-level Python client libraries ecosystem is not well stuffed yet. 11 | 12 | We at [Numberly](https://numberly.com) are strong users (and supporters) of [vaultwarden](https://github.com/dani-garcia/vaultwarden) and needed a way to integrate admin operations into our automation stack. 13 | 14 | We took inspiration from [bitwardentools](https://github.com/corpusops/bitwardentools) and leverage from it internally while adding some admin related features so that we can automate vaultwarden administration tasks. 15 | 16 | Contributions welcomed! 17 | 18 | ## Clients 19 | 20 | There are 2 types of clients: 21 | 22 | - One for the vaultwarden admin API, that needs to be authenticated with an admin token. 23 | - One for the bitwarden API, that needs to be authenticated with the user api keys or user's mail and password. An Owner or Admin user is required to perform admin operations. 24 | 25 | The `reset_account` and `transfer_account_rights` from the Admin client needs a valid Bitwarden client to re-invite the 26 | target user. 27 | 28 | ## Installation 29 | ```bash 30 | pip install python-vaultwarden 31 | ``` 32 | ## Usage 33 | 34 | ### Admin client 35 | 36 | ```python 37 | from vaultwarden.clients.vaultwarden import VaultwardenAdminClient 38 | 39 | client = VaultwardenAdminClient(url="https://vaultwarden.example.com", admin_secret_token="admin_token") 40 | 41 | client.invite("john.doe@example.com") 42 | 43 | all_users = client.get_all_users() 44 | 45 | client.delete(all_users[0].id) 46 | 47 | ``` 48 | 49 | ### Bitwarden client 50 | 51 | ```python 52 | from vaultwarden.clients.bitwarden import BitwardenAPIClient 53 | from vaultwarden.models.bitwarden import Organization, OrganizationCollection, get_organization 54 | 55 | bitwarden_client = BitwardenAPIClient(url="https://vaultwarden.example.com", email="admin@example", password="admin_password", client_id="client_id", client_secret="client_secret") 56 | 57 | org_uuid = "550e8400-e29b-41d4-a716-446655440000" 58 | 59 | orga= get_organization(bitwarden_client, org_uuid) 60 | 61 | collection_id_list = ["666e8400-e29b-41d4-a716-446655440000", "888e8400-e29b-41d4-a716-446655440000", "770e8400-e29b-41d4-a716-446655440000" ] 62 | orga.invite(email="new@example.com", collections=collection_id_list, default_readonly=True, default_hide_passwords=True) 63 | org_users = orga.users() 64 | org_collections: list[OrganizationCollection] = orga.collections() 65 | org_collections_by_name: dict[str: OrganizationCollection] = orga.collections(as_dict=True) 66 | new_coll = orga.create_collection("new_collection") 67 | orga.delete_collection(new_coll.Id) 68 | 69 | my_coll = orga.collection("my_collection") 70 | if new_coll: 71 | users_coll = my_coll.users() 72 | 73 | my_coll_2 = org_collections_by_name["my_coll_2"] 74 | 75 | my_user = orga.users(search="john.doe@example.com") 76 | if my_user: 77 | my_user = my_user[0] 78 | print(my_user.Collections) 79 | my_user.add_collections([my_coll_2.Id]) 80 | 81 | ``` 82 | 83 | ## Credits 84 | 85 | The [crypto part](src/vaultwarden/utils/crypto.py) originates from [bitwardentools](https://github.com/corpusops/bitwardentools). 86 | 87 | 88 | 89 | 90 | [pypi-v-image]: https://img.shields.io/pypi/v/python-vaultwarden.svg 91 | 92 | [pypi-v-link]: https://pypi.org/project/python-vaultwarden/ 93 | 94 | [GHAction-image]: https://github.com/numberly/python-vaultwarden/workflows/CI/badge.svg?branch=main&event=push 95 | 96 | [GHAction-link]: https://github.com/numberly/python-vaultwarden/actions?query=event%3Apush+branch%3Amain 97 | 98 | 99 | 100 | ## Contributing 101 | Thank you for being interested in contributing to `python-vaultwarden`. There are many ways you can contribute to the project: 102 | - Try and report bugs/issues you find 103 | - Implement new features 104 | - Review Pull Requests of others 105 | - Write documentation 106 | - Participate in discussions 107 | 108 | ### Development 109 | To start developing create a fork of the python-vaultwarden repository on GitHub. 110 | 111 | Then clone your fork with the following command replacing YOUR-USERNAME with your GitHub username: 112 | 113 | ```bash 114 | git clone https://github.com/YOUR-USERNAME/python-vaultwarden 115 | ``` 116 | 117 | You can now install the project and its dependencies using: 118 | ```bash 119 | pip install -e .[test] 120 | ``` 121 | ### Testing 122 | To run the tests, use: 123 | 124 | ```bash 125 | bash tests/e2e/run_tests.sh 126 | ``` 127 | 128 | ## License 129 | 130 | Python-vaultwarden is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license. 131 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "python-vaultwarden" 7 | version = "1.0.2" 8 | description = "Admin Vaultwarden and Simple Bitwarden Python Client" 9 | authors = [ 10 | { name = "Lyonel Martinez", email = "lyonel.martinez@numberly.com" }, 11 | { name = "Mathis Ribet", email = "mathis.ribet@numberly.com" }, 12 | ] 13 | license = "Apache-2.0" 14 | readme = "README.md" 15 | repository = "https://github.com/numberly/python-vaultwarden" 16 | documentation = "https://numberly.github.io/python-vaultwarden/" 17 | packages = [ 18 | { include = "vaultwarden", from = "src" }, 19 | ] 20 | classifiers = [ 21 | "Development Status :: 4 - Beta", 22 | "Intended Audience :: Developers", 23 | "Environment :: Web Environment", 24 | "License :: OSI Approved :: Apache Software License", 25 | "Operating System :: OS Independent", 26 | "Intended Audience :: Developers", 27 | "Programming Language :: Python", 28 | "Programming Language :: Python :: 3", 29 | "Programming Language :: Python :: 3 :: Only", 30 | "Programming Language :: Python :: 3.10", 31 | "Programming Language :: Python :: 3.11", 32 | "Typing :: Typed", 33 | "Topic :: Internet :: WWW/HTTP" 34 | ] 35 | requires-python = ">=3.10" 36 | dependencies = [ 37 | "hkdf >=0.0.3", 38 | "pycryptodome >=3.17.0", 39 | "pydantic >=2.5.0", 40 | "httpx >=0.24.1", 41 | ] 42 | [dev-dependencies] 43 | test = [ 44 | "hatch~=1.12", 45 | "pytest~=8.3", 46 | ] 47 | 48 | [tool.hatch.version] 49 | path = "src/vaultwarden/__version__.py" 50 | 51 | [tool.hatch.build] 52 | packages = [ 53 | "src/vaultwarden", 54 | ] 55 | include = [ 56 | "/tests", 57 | ] 58 | 59 | [tool.hatch.build.targets.sdist] 60 | include = ["/src/vaultwarden/**/*.py"] 61 | [tool.hatch.build.targets.wheel] 62 | packages = [ 63 | "src/vaultwarden", 64 | ] 65 | 66 | [tool.hatch.envs.test] 67 | dependencies = [ 68 | "coverage", 69 | ] 70 | 71 | [tool.hatch.envs.test.scripts] 72 | test = "coverage run --source=src/vaultwarden -m unittest discover -p 'test_*.py' tests --top-level-directory ." 73 | _coverage = ["test", "coverage xml", "coverage report --show-missing"] 74 | with-coverage = "test" 75 | [[tool.hatch.envs.test.matrix]] 76 | python = ["3.10", "3.11", "3.12", "3.13"] 77 | type = ["default"] 78 | [tool.hatch.envs.test.overrides] 79 | matrix.type.scripts = [ 80 | { key = "with-coverage", value = "_coverage", if = ["default"] }, 81 | ] 82 | 83 | [tool.hatch.envs.types] 84 | dependencies = [ 85 | "mypy", 86 | "types-PyYAML", 87 | "types-setuptools", 88 | "typing-extensions", 89 | ] 90 | [tool.hatch.envs.types.scripts] 91 | check = "mypy src/vaultwarden" 92 | 93 | [tool.hatch.envs.style] 94 | detached = true 95 | dependencies = [ 96 | "black", 97 | "isort", 98 | "ruff", 99 | ] 100 | [tool.hatch.envs.style.scripts] 101 | lint = [ 102 | "ruff check --fix src/vaultwarden", 103 | ] 104 | check = [ 105 | "isort --check-only --diff src/vaultwarden", 106 | "black -q --check --diff src/vaultwarden", 107 | "ruff check src/vaultwarden", 108 | ] 109 | format = [ 110 | "isort -q src/vaultwarden", 111 | "black -q src/vaultwarden", 112 | "lint" 113 | ] 114 | 115 | [tool.ruff] 116 | # Add "Q" to the list of enabled codes. 117 | select = ["B", "E", "F", "I", "N", "Q", "RUF", "SIM", "TCH"] 118 | ignore = ["N815"] 119 | fixable = ["ALL"] 120 | src = ["src/vaultwarden", "tests"] 121 | exclude = ["src/vaultwarden/utils/crypto.py"] 122 | target-version = "py310" 123 | line-length = 79 124 | 125 | [tool.ruff.flake8-quotes] 126 | docstring-quotes = "double" 127 | 128 | [tool.ruff.flake8-bugbear] 129 | extend-immutable-calls = ["typer.Argument"] 130 | 131 | [tool.ruff.isort] 132 | force-sort-within-sections = true 133 | 134 | [tool.black] 135 | line-length = 79 136 | target-version = ["py310", "py311"] 137 | 138 | [tool.isort] 139 | profile = "black" 140 | line_length = 80 141 | 142 | [tool.mypy] 143 | ignore_missing_imports = true 144 | warn_unreachable = true 145 | no_implicit_optional = true 146 | show_error_codes = true 147 | plugins = [ 148 | "pydantic.mypy" 149 | ] 150 | 151 | [tool.commitizen] 152 | version = "1.0.2" 153 | tag_format = "$version" 154 | update_changelog_on_bump = true 155 | version_files = [ 156 | "pyproject.toml", 157 | "src/vaultwarden/__version__.py", 158 | ] 159 | -------------------------------------------------------------------------------- /src/vaultwarden/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numberly/python-vaultwarden/964e13b708a9b3c4f8e7c6352db41506a88ecff1/src/vaultwarden/__init__.py -------------------------------------------------------------------------------- /src/vaultwarden/__version__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.0.2" 2 | -------------------------------------------------------------------------------- /src/vaultwarden/clients/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numberly/python-vaultwarden/964e13b708a9b3c4f8e7c6352db41506a88ecff1/src/vaultwarden/clients/__init__.py -------------------------------------------------------------------------------- /src/vaultwarden/clients/bitwarden.py: -------------------------------------------------------------------------------- 1 | from typing import Literal 2 | from uuid import UUID 3 | 4 | from httpx import Client, Response 5 | 6 | from vaultwarden.models.exception_models import BitwardenError 7 | from vaultwarden.models.sync import ConnectToken, SyncData 8 | from vaultwarden.utils.crypto import make_master_key 9 | from vaultwarden.utils.logger import log_raise_for_status 10 | 11 | 12 | class BitwardenAPIClient: 13 | def __init__( 14 | self, 15 | url: str, 16 | email: str, 17 | password: str, 18 | client_id: str, 19 | client_secret: str, 20 | device_id: UUID | str, 21 | timeout: int = 30, 22 | ): 23 | # if one of the parameters is None, raise an exception 24 | if not all( 25 | [url, email, password, client_id, client_secret, device_id] 26 | ): 27 | raise BitwardenError("All parameters are required") 28 | self.email = email 29 | self.password = password 30 | self.client_id = client_id 31 | self.client_secret = client_secret 32 | self.device_id = device_id 33 | self.url = url.strip("/") 34 | self._http_client = Client( 35 | base_url=f"{self.url}/", 36 | event_hooks={"response": [log_raise_for_status]}, 37 | timeout=timeout, 38 | ) 39 | self._connect_token: ConnectToken | None = None 40 | self._sync: SyncData | None = None 41 | 42 | @property 43 | def connect_token(self) -> ConnectToken | None: 44 | return self._connect_token 45 | 46 | @connect_token.setter 47 | def connect_token(self, value: ConnectToken): 48 | self._connect_token = value 49 | 50 | # refresh connect token if expired 51 | def _refresh_connect_token(self): 52 | if ( 53 | self.connect_token is None 54 | or self.connect_token.refresh_token is None 55 | ): 56 | self._set_connect_token() 57 | return 58 | headers = { 59 | "content-type": "application/x-www-form-urlencoded; charset=utf-8", 60 | } 61 | payload = { 62 | "grant_type": "refresh_token", 63 | "refresh_token": self.connect_token.refresh_token, 64 | } 65 | resp = self._http_client.post( 66 | "identity/connect/token", headers=headers, data=payload 67 | ) 68 | self._connect_token = ConnectToken.model_validate_json(resp.text) 69 | 70 | self._connect_token.master_key = make_master_key( 71 | password=self.password, 72 | salt=self.email, 73 | iterations=self._connect_token.KdfIterations, 74 | ) 75 | 76 | def _set_connect_token(self): 77 | headers = { 78 | "content-type": "application/x-www-form-urlencoded; charset=utf-8", 79 | } 80 | payload = { 81 | "grant_type": "client_credentials", 82 | "client_secret": f"{self.client_secret}", 83 | "client_id": f"{self.client_id}", 84 | "scope": "api", 85 | # 21 for "SDK", see https://github.com/bitwarden/server/blob/master/src/Core/Enums/DeviceType.cs 86 | "deviceType": 21, 87 | "deviceIdentifier": f"{self.device_id}", 88 | "deviceName": "python-vaultwarden", 89 | } 90 | resp = self._http_client.post( 91 | "identity/connect/token", headers=headers, data=payload 92 | ) 93 | self._connect_token = ConnectToken.model_validate_json(resp.text) 94 | self._connect_token.master_key = make_master_key( 95 | password=self.password, 96 | salt=self.email, 97 | iterations=self._connect_token.KdfIterations, 98 | ) 99 | 100 | # login to api 101 | def _api_login(self) -> None: 102 | if self.connect_token is not None: 103 | if self.connect_token.is_expired(): 104 | self._refresh_connect_token() 105 | return 106 | 107 | self._set_connect_token() 108 | 109 | def api_request( 110 | self, 111 | method: Literal["GET", "POST", "DELETE", "PUT"], 112 | path: str, 113 | **kwargs, 114 | ) -> Response: 115 | return self._api_request(method, path, **kwargs) 116 | 117 | def _api_request( 118 | self, 119 | method: Literal["GET", "POST", "DELETE", "PUT"], 120 | path: str, 121 | **kwargs, 122 | ) -> Response: 123 | self._api_login() 124 | if self.connect_token is None: 125 | raise BitwardenError("Fail to connect") 126 | headers = { 127 | "Authorization": f"Bearer {self.connect_token.access_token}", 128 | "content-type": "application/json; charset=utf-8", 129 | "Accept": "*/*", 130 | } 131 | return self._http_client.request( 132 | method, path, headers=headers, **kwargs 133 | ) 134 | 135 | def sync(self, force_refresh: bool = False) -> SyncData: 136 | if self._sync is None or force_refresh: 137 | resp = self._api_request("GET", "api/sync") 138 | self._sync = SyncData.model_validate_json(resp.text) 139 | return self._sync 140 | -------------------------------------------------------------------------------- /src/vaultwarden/clients/vaultwarden.py: -------------------------------------------------------------------------------- 1 | import http 2 | from http.cookiejar import Cookie 3 | from typing import Any, Literal 4 | from uuid import UUID 5 | 6 | from httpx import Client, HTTPStatusError, Response 7 | from pydantic import TypeAdapter 8 | 9 | from vaultwarden.clients.bitwarden import BitwardenAPIClient 10 | from vaultwarden.models.bitwarden import get_organization 11 | from vaultwarden.models.enum import VaultwardenUserStatus 12 | from vaultwarden.models.exception_models import VaultwardenAdminError 13 | from vaultwarden.models.sync import VaultwardenUser 14 | from vaultwarden.utils.logger import log_raise_for_status, logger 15 | 16 | 17 | class VaultwardenAdminClient: 18 | _users: list[VaultwardenUser] 19 | _users_index: dict[UUID, int] 20 | _users_alias: dict[str, UUID] 21 | 22 | def __init__( 23 | self, 24 | url: str, 25 | admin_secret_token: str, 26 | preload_users: bool, 27 | timeout: int = 30, 28 | ): 29 | # If url or admin_secret_token is None, raise an exception 30 | if not url or not admin_secret_token: 31 | raise VaultwardenAdminError("Missing url or admin_secret_token") 32 | self.admin_secret_token = admin_secret_token 33 | self.url = url.strip("/") 34 | self._http_client = Client( 35 | base_url=f"{self.url}/admin/", 36 | event_hooks={"response": [log_raise_for_status]}, 37 | timeout=timeout, 38 | ) 39 | self._users_index = {} 40 | self._users_alias = {} 41 | self._users = [] 42 | # Preload all users infos 43 | if preload_users: 44 | self._load_users() 45 | 46 | def _get_admin_cookie(self) -> Cookie | None: 47 | """Get the session cookie, required to authenticate requests""" 48 | bw_cookies = ( 49 | c for c in self._http_client.cookies.jar if c.name == "VW_ADMIN" 50 | ) 51 | return next(bw_cookies, None) 52 | 53 | def _admin_login(self) -> None: 54 | cookie = self._get_admin_cookie() 55 | 56 | if cookie and not cookie.is_expired(): 57 | # Cookie is valid, nothing to do 58 | return 59 | 60 | # Refresh 61 | self._http_client.post("", data={"token": self.admin_secret_token}) 62 | 63 | def _admin_request( 64 | self, method: Literal["GET", "POST"], path: str, **kwargs: Any 65 | ) -> Response: 66 | self._admin_login() 67 | return self._http_client.request(method, path, **kwargs) 68 | 69 | def _load_users(self) -> None: 70 | resp = self._admin_request("GET", "users") 71 | self._users = TypeAdapter(list[VaultwardenUser]).validate_json( 72 | resp.text 73 | ) 74 | self._users_index = {u.Id: i for i, u in enumerate(self._users)} 75 | self._users_alias = {u.Email: u.Id for u in self._users} 76 | 77 | def user( 78 | self, email=None, uuid=None, force_refresh=False 79 | ) -> VaultwardenUser: 80 | if email is None and uuid is None: 81 | raise VaultwardenAdminError("Missing email or id") 82 | if email is not None and uuid is not None: 83 | raise VaultwardenAdminError("Both email and id given") 84 | if force_refresh or not self._users: 85 | self._load_users() 86 | res_uuid = uuid 87 | if email is not None: 88 | res_uuid = self._users_alias.get(email) 89 | if res_uuid is None: 90 | raise VaultwardenAdminError(f"User '{email}' not found") 91 | index = self._users_index.get(res_uuid) 92 | if index is None: 93 | raise VaultwardenAdminError(f"User '{res_uuid}' not found") 94 | return self._users[index] 95 | 96 | def get_user( 97 | self, email=None, uuid=None, force_refresh=False 98 | ) -> VaultwardenUser | None: 99 | try: 100 | return self.user( 101 | email=email, uuid=uuid, force_refresh=force_refresh 102 | ) 103 | except VaultwardenAdminError: 104 | return None 105 | 106 | def users( 107 | self, 108 | as_email_dict=False, 109 | as_uuid_dict=False, 110 | force_refresh=False, 111 | mfa: bool | None = None, 112 | enabled: bool | None = None, 113 | exclude_invited: bool = False, 114 | ) -> ( 115 | list[VaultwardenUser] 116 | | dict[str, VaultwardenUser] 117 | | dict[UUID, VaultwardenUser] 118 | ): 119 | if force_refresh or not self._users: 120 | self._load_users() 121 | res = self._users 122 | if mfa is not None: 123 | res = [u for u in self._users if u.TwoFactorEnabled == mfa] 124 | if enabled is not None: 125 | res = [u for u in res if u.UserEnabled == enabled] 126 | if exclude_invited: 127 | res = [u for u in res if u.status != VaultwardenUserStatus.Invited] 128 | if as_email_dict: 129 | return {u.Email: u for u in res} 130 | if as_uuid_dict: 131 | return {u.Id: u for u in res} 132 | return res 133 | 134 | # User Management Part 135 | def invite(self, email: str) -> bool: 136 | res = True 137 | try: 138 | self._admin_request("POST", "invite", json={"email": email}) 139 | except HTTPStatusError as e: 140 | res = e.response.status_code == http.HTTPStatus.CONFLICT 141 | if not res: 142 | logger.warning(f"Failed to invite {email}") 143 | else: 144 | self._load_users() 145 | return res 146 | 147 | def delete(self, identifier: str | UUID) -> bool: 148 | logger.info(f"Deleting {identifier} account") 149 | res = True 150 | try: 151 | self._admin_request("POST", f"users/{identifier}/delete") 152 | except HTTPStatusError: 153 | res = False 154 | if not res: 155 | logger.warning(f"Failed to delete {identifier}") 156 | else: 157 | self._load_users() 158 | return res 159 | 160 | def set_user_enabled(self, identifier: str | UUID, enabled: bool) -> None: 161 | """Disabling a user also deauthorizes all its sessions""" 162 | if enabled: 163 | resp = self._admin_request("POST", f"users/{identifier}/enable") 164 | else: 165 | resp = self._admin_request("POST", f"users/{identifier}/disable") 166 | resp.raise_for_status() 167 | 168 | def remove_2fa(self, uuid=None, email=None) -> bool: 169 | user = self.get_user(uuid=uuid, email=email) 170 | if user is None: 171 | logger.warning(f"User '{uuid}' not found") 172 | return False 173 | if not user.TwoFactorEnabled: 174 | logger.warning(f"User '{uuid}' has no 2FA enabled") 175 | return False 176 | try: 177 | self._admin_request("POST", f"users/{uuid}/remove-2fa") 178 | except HTTPStatusError: 179 | logger.warning(f"Failed to remove 2FA for {uuid}") 180 | return False 181 | return True 182 | 183 | def reset_account( 184 | self, email: str, admin_bitwarden_client: BitwardenAPIClient 185 | ): 186 | user: VaultwardenUser = self.user(email=email) 187 | warning = False 188 | orgs = [] 189 | for profile_org in user.Organizations: 190 | try: 191 | orgs.append( 192 | get_organization(admin_bitwarden_client, profile_org.Id) 193 | ) 194 | except HTTPStatusError: 195 | logger.warning( 196 | f"Given Bitwarden client has no access to org" 197 | f" '{profile_org.Name}' ({profile_org.Id})" 198 | ) 199 | warning = True 200 | if warning: 201 | check = input( 202 | "WARNING: A organisation where you where present is not " 203 | "maintain by SOC account\n" 204 | "Type 'yes' if you still want to reset the account" 205 | ) 206 | if check != "yes": 207 | logger.warning(f"'{check}' != of 'yes' - Cancelling the reset") 208 | return 209 | logger.warning( 210 | f"Doing reset on {email} despite having not complete " 211 | f"information on its accesses" 212 | ) 213 | self.delete(str(user.Id)) 214 | for org in orgs: 215 | users_org = org.users(search=email) 216 | if len(users_org) > 0: 217 | user_details = users_org[0] 218 | org.invite( 219 | email, 220 | collections=user_details.Collections, 221 | access_all=user_details.AccessAll, 222 | user_type=user_details.Type, 223 | ) 224 | if len(orgs) == 0: 225 | logger.warning("No organisation in the rights") 226 | self.invite(email) 227 | return None 228 | 229 | def transfer_account_rights( 230 | self, 231 | previous_email: str, 232 | new_email: str, 233 | admin_bitwarden_client: BitwardenAPIClient, 234 | ): 235 | user: VaultwardenUser = self.user(email=previous_email) 236 | orgs = [] 237 | for profile_org in user.Organizations: 238 | try: 239 | orgs.append( 240 | get_organization(admin_bitwarden_client, profile_org.Id) 241 | ) 242 | except Exception: 243 | logger.warning( 244 | f"Given Bitwarden client has no access to org " 245 | f"'{profile_org.Name}' ({profile_org.Id})" 246 | ) 247 | if len(orgs) == 0: 248 | logger.warning("No organisation in the rights") 249 | self.invite(new_email) 250 | for org in orgs: 251 | users_org = org.users(search=previous_email) 252 | if len(users_org) > 0: 253 | user_details = users_org[0] 254 | org.invite( 255 | new_email, 256 | collections=user_details.Collections, 257 | access_all=user_details.AccessAll, 258 | user_type=user_details.Type, 259 | ) 260 | self.set_user_enabled(str(user.Id), enabled=False) 261 | -------------------------------------------------------------------------------- /src/vaultwarden/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numberly/python-vaultwarden/964e13b708a9b3c4f8e7c6352db41506a88ecff1/src/vaultwarden/models/__init__.py -------------------------------------------------------------------------------- /src/vaultwarden/models/bitwarden.py: -------------------------------------------------------------------------------- 1 | from typing import Generic, Literal, TypeVar, cast 2 | from uuid import UUID 3 | 4 | from pydantic import AliasChoices, Field, TypeAdapter, field_validator 5 | from pydantic_core.core_schema import FieldValidationInfo 6 | 7 | from vaultwarden.clients.bitwarden import BitwardenAPIClient 8 | from vaultwarden.models.enum import CipherType, OrganizationUserType 9 | from vaultwarden.models.exception_models import BitwardenError 10 | from vaultwarden.models.permissive_model import PermissiveBaseModel 11 | from vaultwarden.utils.crypto import decrypt, encrypt 12 | 13 | # Pydantic models for Bitwarden data structures 14 | 15 | T = TypeVar("T", bound="BitwardenBaseModel") 16 | 17 | 18 | class ResplistBitwarden(PermissiveBaseModel, Generic[T]): 19 | Data: list[T] 20 | 21 | 22 | class BitwardenBaseModel(PermissiveBaseModel): 23 | bitwarden_client: BitwardenAPIClient | None = Field( 24 | default=None, validate_default=True, exclude=True 25 | ) 26 | 27 | @field_validator("bitwarden_client") 28 | @classmethod 29 | def set_client(cls, v, info: FieldValidationInfo): 30 | if v is None and info.context is not None: 31 | return info.context.get("client") 32 | return v 33 | 34 | @property 35 | def api_client(self) -> BitwardenAPIClient: 36 | assert self.bitwarden_client is not None 37 | return self.bitwarden_client 38 | 39 | 40 | class CipherDetails(BitwardenBaseModel): 41 | Id: UUID | None = None 42 | OrganizationId: UUID | None = Field(None, validate_default=True) 43 | Type: CipherType 44 | Name: str 45 | CollectionIds: list[UUID] 46 | 47 | @field_validator("OrganizationId") 48 | @classmethod 49 | def set_id(cls, v, info: FieldValidationInfo): 50 | if v is None and info.context is not None: 51 | return info.context.get("parent_id") 52 | return v 53 | 54 | def add_collections(self, collections: list[UUID]): 55 | _current_collections = self.CollectionIds 56 | for collection in collections: 57 | if collection in _current_collections: 58 | continue 59 | self.CollectionIds.append(collection) 60 | dump = [str(coll_id) for coll_id in self.CollectionIds] 61 | return self.api_client.api_request( 62 | "POST", 63 | f"api/ciphers/{self.Id}/collections", 64 | json={"collectionIds": dump}, 65 | ) 66 | 67 | def remove_collections(self, collections: list[UUID]): 68 | self.CollectionIds = [ 69 | coll for coll in self.CollectionIds if coll not in collections 70 | ] 71 | dump = [str(coll_id) for coll_id in self.CollectionIds] 72 | return self.api_client.api_request( 73 | "POST", 74 | f"api/ciphers/{self.Id}/collections", 75 | json={"collectionIds": dump}, 76 | ) 77 | 78 | def delete(self): 79 | return self.api_client.api_request("DELETE", f"api/ciphers/{self.Id}") 80 | 81 | def update_collection(self, collections: list[UUID]): 82 | dump = [str(coll_id) for coll_id in collections] 83 | self.CollectionIds = collections 84 | return self.api_client.api_request( 85 | "POST", 86 | f"api/ciphers/{self.Id}/collections", 87 | json={"collectionIds": dump}, 88 | ) 89 | 90 | 91 | class CollectionAccess(BitwardenBaseModel): 92 | ReadOnly: bool = False 93 | HidePasswords: bool = False 94 | Manage: bool = False 95 | 96 | 97 | class CollectionUser(CollectionAccess): 98 | CollectionId: UUID | None = Field(None, validate_default=True) 99 | UserId: UUID | None = Field( 100 | None, 101 | validation_alias=AliasChoices("id", "Id"), 102 | serialization_alias="id", 103 | ) 104 | 105 | @field_validator("CollectionId") 106 | @classmethod 107 | def set_id(cls, v, info: FieldValidationInfo): 108 | if v is None and info.context is not None: 109 | return info.context.get("parent_id") 110 | return v 111 | 112 | 113 | class UserCollection(CollectionAccess): 114 | CollectionId: UUID | None = Field( 115 | None, 116 | validation_alias=AliasChoices("id", "Id"), 117 | serialization_alias="id", 118 | ) 119 | UserId: UUID | None = Field(None, validate_default=True) 120 | 121 | @field_validator("UserId") 122 | @classmethod 123 | def set_id(cls, v, info: FieldValidationInfo): 124 | if v is None and info.context is not None: 125 | return info.context.get("parent_id") 126 | return v 127 | 128 | 129 | class OrganizationCollection(BitwardenBaseModel): 130 | Id: UUID | None = None 131 | OrganizationId: UUID | None = Field(None, validate_default=True) 132 | Name: str 133 | ExternalId: str | None = None 134 | 135 | @field_validator("OrganizationId") 136 | @classmethod 137 | def set_id(cls, v, info: FieldValidationInfo): 138 | if v is None and info.context is not None: 139 | return info.context.get("parent_id") 140 | return v 141 | 142 | def users(self) -> list[CollectionUser]: 143 | resp = self.api_client.api_request( 144 | "GET", 145 | f"api/organizations/{self.OrganizationId}/collections/{self.Id}/users", 146 | params={"includeCollections": True, "includeGroups": True}, 147 | ) 148 | return TypeAdapter(list[CollectionUser]).validate_json( 149 | resp.text, 150 | context={"parent_id": self.Id, "client": self.api_client}, 151 | ) 152 | 153 | def set_users( 154 | self, 155 | users: list[CollectionUser] | list[UUID], 156 | default_readonly: bool = False, 157 | default_hide_passwords: bool = False, 158 | default_manage: bool = False, 159 | ): 160 | users_payload = [] 161 | if users is not None and len(users) > 0: 162 | if isinstance(users[0], CollectionUser): 163 | users = cast("list[CollectionUser]", users) 164 | users_payload = [ 165 | user.model_dump( 166 | exclude={"CollectionId"}, by_alias=True, mode="json" 167 | ) 168 | for user in users 169 | ] 170 | else: 171 | users = cast("list[UUID]", users) 172 | users_payload = [ 173 | { 174 | "id": str(user_id), 175 | "readOnly": default_readonly, 176 | "hidePasswords": default_hide_passwords, 177 | "manage": default_manage, 178 | } 179 | for user_id in users 180 | ] 181 | return self.api_client.api_request( 182 | "PUT", 183 | f"api/organizations/{self.OrganizationId}/collections/{self.Id}/users", 184 | json=users_payload, 185 | ) 186 | 187 | # Delete collection 188 | def delete(self): 189 | return self.api_client.api_request( 190 | "DELETE", 191 | f"api/organizations/{self.OrganizationId}/collections/{self.Id}", 192 | ) 193 | 194 | 195 | class OrganizationUserDetails(BitwardenBaseModel): 196 | Id: UUID | None = None 197 | Email: str 198 | UserId: UUID | None = None 199 | OrganizationId: UUID | None = Field(None, validate_default=True) 200 | Status: int 201 | Type: OrganizationUserType 202 | AccessAll: bool 203 | ExternalId: str | None 204 | Key: str | None = None 205 | ResetPasswordKey: str | None = None 206 | Collections: list[UserCollection] 207 | Groups: list | None = None 208 | TwoFactorEnabled: bool 209 | Permissions: dict | None = None 210 | 211 | @field_validator("OrganizationId") 212 | @classmethod 213 | def set_id(cls, v, info: FieldValidationInfo): 214 | if v is None and info.context is not None: 215 | return info.context.get("parent_id") 216 | return v 217 | 218 | def add_collections(self, collections: list[UUID]): 219 | _current_collections = [coll.CollectionId for coll in self.Collections] 220 | for collection in collections: 221 | if collection in _current_collections: 222 | continue 223 | user = UserCollection( 224 | CollectionId=collection, 225 | UserId=self.Id, 226 | ReadOnly=False, 227 | HidePasswords=False, 228 | Manage=False, 229 | ) 230 | user.bitwarden_client = self.api_client 231 | self.Collections.append(user) 232 | pl = self.model_dump( 233 | include={ 234 | "Collections": { 235 | "__all__": { 236 | "CollectionId": True, 237 | "ReadOnly": True, 238 | "HidePasswords": True, 239 | "Manage": True, 240 | } 241 | }, 242 | "Groups": True, 243 | "Type": True, 244 | "AccessAll": True, 245 | }, 246 | by_alias=True, 247 | mode="json", 248 | ) 249 | return ( 250 | self.api_client.api_request( 251 | "POST", 252 | f"api/organizations/{self.OrganizationId}/users/{self.Id}", 253 | json=pl, 254 | ), 255 | ) 256 | 257 | # TODO add collections as list of CollectionUser 258 | def remove_collections(self, collections: list[UUID]): 259 | self.Collections = [ 260 | coll 261 | for coll in self.Collections 262 | if coll.CollectionId not in collections 263 | ] 264 | pl = self.model_dump( 265 | include={ 266 | "Collections": { 267 | "__all__": { 268 | "Id", 269 | "CollectionId", 270 | "ReadOnly", 271 | "HidePasswords", 272 | } 273 | }, 274 | "Groups": True, 275 | "Type": True, 276 | "AccessAll": True, 277 | }, 278 | by_alias=True, 279 | mode="json", 280 | ) 281 | return self.api_client.api_request( 282 | "POST", 283 | f"api/organizations/{self.OrganizationId}/users/{self.Id}", 284 | json=pl, 285 | ) 286 | 287 | def update_collection(self, collections: list[UUID]): 288 | self.Collections = [ 289 | UserCollection( 290 | UserId=self.Id, 291 | CollectionId=coll, 292 | ReadOnly=False, 293 | HidePasswords=False, 294 | ) 295 | for coll in collections 296 | ] 297 | return self.api_client.api_request( 298 | "POST", 299 | f"api/organizations/{self.OrganizationId}/users/{self.Id}", 300 | json=self.model_dump( 301 | include={ 302 | "Collections": { 303 | "__all__": { 304 | "CollectionId", 305 | "ReadOnly", 306 | "HidePasswords", 307 | } 308 | }, 309 | "Groups": True, 310 | "Type": True, 311 | "AccessAll": True, 312 | }, 313 | by_alias=True, 314 | mode="json", 315 | ), 316 | ) 317 | 318 | def delete(self): 319 | return self.api_client.api_request( 320 | "DELETE", 321 | f"api/organizations/{self.OrganizationId}/users/{self.Id}", 322 | ) 323 | 324 | 325 | class CollectionCipher(BitwardenBaseModel): 326 | CollectionId: UUID 327 | CipherId: UUID 328 | 329 | 330 | class Organization(BitwardenBaseModel): 331 | Id: UUID | None = Field(None, validate_default=True) 332 | Name: str 333 | Object: str | None 334 | _collections: list[OrganizationCollection] | None = None 335 | _users: list[OrganizationUserDetails] | None = None 336 | _ciphers: list[CipherDetails] | None = None 337 | 338 | @field_validator("Id") 339 | @classmethod 340 | def set_id(cls, v, info: FieldValidationInfo): 341 | if v is None and info.context is not None: 342 | return info.context.get("parent_id") 343 | return v 344 | 345 | def invite( 346 | self, 347 | email, 348 | collections: ( 349 | list[UserCollection] 350 | | list[OrganizationCollection] 351 | | list[UUID] 352 | | list[str] 353 | | None 354 | ) = None, 355 | access_all: bool = False, 356 | user_type: OrganizationUserType = OrganizationUserType.User, 357 | permissions=None, 358 | default_readonly: bool = False, 359 | default_hide_passwords: bool = False, 360 | default_manage: bool = False, 361 | ): 362 | if permissions is None: 363 | permissions = {} 364 | collections_payload = [] 365 | if collections is not None and len(collections) > 0: 366 | for coll in collections: 367 | if isinstance(coll, UserCollection): 368 | coll = cast("UserCollection", coll) 369 | ex: dict[str, Literal[True]] = {"UserId": True} 370 | collections_payload.append( 371 | coll.model_dump( 372 | by_alias=True, 373 | mode="json", 374 | exclude=ex, 375 | ) 376 | ) 377 | else: 378 | if isinstance(coll, OrganizationCollection): 379 | coll = cast("OrganizationCollection", coll) 380 | coll_id = str(coll.Id) 381 | elif isinstance(coll, UUID): 382 | coll = cast("UUID", coll) 383 | coll_id = str(coll) 384 | else: 385 | coll_id = cast("str", coll) 386 | collections_payload.append( 387 | { 388 | "id": coll_id, 389 | "readOnly": default_readonly, 390 | "hidePasswords": default_hide_passwords, 391 | "manage": default_manage, 392 | } 393 | ) 394 | 395 | payload = { 396 | "emails": [email], 397 | "accessAll": access_all, 398 | "type": user_type, 399 | "collections": collections_payload, 400 | "groups": [], 401 | "permissions": permissions, 402 | } 403 | resp = self.api_client.api_request( 404 | "POST", f"api/organizations/{self.Id}/users/invite", json=payload 405 | ) 406 | self._users = self._get_users() 407 | return resp 408 | 409 | def _get_users(self) -> list[OrganizationUserDetails]: 410 | resp = self.api_client.api_request( 411 | "GET", 412 | f"api/organizations/{self.Id}/users", 413 | params={"includeCollections": True, "includeGroups": True}, 414 | ) 415 | return ( 416 | ResplistBitwarden[OrganizationUserDetails] 417 | .model_validate_json( 418 | resp.text, 419 | context={ 420 | "parent_id": self.Id, 421 | "client": self.api_client, 422 | }, 423 | ) 424 | .Data 425 | ) 426 | 427 | def users( 428 | self, 429 | force_refresh: bool = False, 430 | mfa: bool | None = None, 431 | search: str | UUID | None = None, 432 | ) -> list[OrganizationUserDetails]: 433 | if self._users is None or force_refresh: 434 | self._users = self._get_users() 435 | res = self._users 436 | if mfa is not None: 437 | res = [ 438 | user for user in self._users if user.TwoFactorEnabled == mfa 439 | ] 440 | if search: 441 | for user in res: 442 | if search == user.Email or search == user.Id: 443 | return [user] 444 | return [] 445 | return res 446 | 447 | def user(self, user_id: UUID) -> OrganizationUserDetails: 448 | resp = self.api_client.api_request( 449 | "GET", 450 | f"api/organizations/{self.Id}/users/{user_id}", 451 | params={"includeCollections": True, "includeGroups": True}, 452 | ) 453 | return OrganizationUserDetails.model_validate_json( 454 | resp.text, 455 | context={"parent_id": self.Id, "client": self.api_client}, 456 | ) 457 | 458 | def user_search( 459 | self, 460 | email: str, 461 | mfa: bool | None = None, 462 | force_refresh: bool = False, 463 | ) -> OrganizationUserDetails | None: 464 | users = self.users(search=email, mfa=mfa, force_refresh=force_refresh) 465 | if len(users) == 0: 466 | return None 467 | return users[0] 468 | 469 | def _get_collections(self) -> list[OrganizationCollection]: 470 | resp = self.api_client.api_request( 471 | "GET", f"api/organizations/{self.Id}/collections" 472 | ) 473 | res = ResplistBitwarden[OrganizationCollection].model_validate_json( 474 | resp.text, 475 | context={"parent_id": self.Id, "client": self.api_client}, 476 | ) 477 | org_key = self.key() 478 | # map each collection name to the decrypted name 479 | for collection in res.Data: 480 | collection.Name = decrypt(collection.Name, org_key).decode("utf-8") 481 | return res.Data 482 | 483 | def collections( 484 | self, force_refresh: bool = False, as_dict: bool = False 485 | ) -> list[OrganizationCollection] | dict[str, OrganizationCollection]: 486 | if self._collections is None or force_refresh: 487 | self._collections = self._get_collections() 488 | if as_dict: 489 | return {coll.Name: coll for coll in self._collections} 490 | return self._collections 491 | 492 | def create_collection(self, name: str) -> OrganizationCollection: 493 | org_key = self.key() 494 | data = { 495 | "name": encrypt(2, name, self.key()), 496 | "groups": [], 497 | "users": [], 498 | } 499 | resp = self.api_client.api_request( 500 | "POST", f"api/organizations/{self.Id}/collections", json=data 501 | ) 502 | res = OrganizationCollection.model_validate_json( 503 | resp.text, 504 | context={"parent_id": self.Id, "client": self.api_client}, 505 | ) 506 | res.Name = decrypt(res.Name, org_key).decode("utf-8") 507 | if self._collections is not None: 508 | self._collections.append(res) 509 | else: 510 | self._collections = [res] 511 | return res 512 | 513 | def delete_collection(self, collection_id: UUID): 514 | resp = self.api_client.api_request( 515 | "DELETE", 516 | f"api/organizations/{self.Id}/collections/{collection_id}", 517 | ) 518 | self._collections = self._get_collections() 519 | return resp 520 | 521 | def collection(self, name) -> OrganizationCollection | None: 522 | self.collections() 523 | if self._collections is None: 524 | return None 525 | for collection in self._collections: 526 | if collection.Name == name: 527 | return collection 528 | return None 529 | 530 | def _get_ciphers(self) -> list[CipherDetails]: 531 | resp = self.api_client.api_request( 532 | "GET", 533 | "api/ciphers/organization-details", 534 | params={"organizationId": self.Id}, 535 | ) 536 | res = ResplistBitwarden[CipherDetails].model_validate_json( 537 | resp.text, 538 | context={"parent_id": self.Id, "client": self.api_client}, 539 | ) 540 | org_key = self.key() 541 | # map each cipher name to the decrypted name 542 | for cipher in res.Data: 543 | cipher.Name = decrypt(cipher.Name, org_key).decode("utf-8") 544 | return res.Data 545 | 546 | def ciphers( 547 | self, collection: UUID | None = None, force_refresh: bool = False 548 | ) -> list[CipherDetails]: 549 | """ 550 | Get all ciphers for an organization 551 | :param collection: get ciphers for a specific collection 552 | :param force_refresh: force a refresh of the ciphers 553 | :return: 554 | """ 555 | if self._ciphers is None or force_refresh: 556 | self._ciphers = self._get_ciphers() 557 | if collection is not None: 558 | return [ 559 | cipher 560 | for cipher in self._ciphers 561 | if collection in cipher.CollectionIds 562 | ] 563 | return self._ciphers 564 | 565 | def key(self): 566 | sync = self.api_client.sync() 567 | raw_key = None 568 | for org in sync.Profile.Organizations: 569 | if org.Id == self.Id: 570 | raw_key = org.Key 571 | break 572 | if raw_key is not None: 573 | return decrypt(raw_key, self.api_client.connect_token.orgs_key) 574 | raise BitwardenError(f"No Organizations `{self.Id}` found") 575 | 576 | 577 | def get_organization( 578 | bitwarden_client, organisation_id: UUID | str 579 | ) -> Organization: 580 | resp = bitwarden_client.api_request( 581 | "GET", f"api/organizations/{organisation_id}" 582 | ) 583 | return Organization.model_validate_json( 584 | resp.text, 585 | context={"client": bitwarden_client, "parent_id": organisation_id}, 586 | ) 587 | -------------------------------------------------------------------------------- /src/vaultwarden/models/enum.py: -------------------------------------------------------------------------------- 1 | from enum import IntEnum 2 | 3 | 4 | class OrganizationUserStatus(IntEnum): 5 | Revoked = -1 6 | Invited = 0 7 | Accepted = 1 8 | Confirmed = 2 9 | 10 | 11 | class OrganizationUserType(IntEnum): 12 | Owner = 0 13 | Admin = 1 14 | User = 2 15 | Manager = 3 16 | Custom = 4 17 | 18 | 19 | class CipherType(IntEnum): 20 | Login = 1 21 | SecureNote = 2 22 | Card = 3 23 | Identity = 4 24 | 25 | 26 | class VaultwardenUserStatus(IntEnum): 27 | Enabled = 0 28 | Invited = 1 29 | Disabled = 2 30 | -------------------------------------------------------------------------------- /src/vaultwarden/models/exception_models.py: -------------------------------------------------------------------------------- 1 | class BitwardenError(Exception): 2 | """BitwardenClient Exception class""" 3 | 4 | pass 5 | 6 | 7 | class VaultwardenAdminError(Exception): 8 | """VaultwardenAdminClient Exception class""" 9 | 10 | pass 11 | -------------------------------------------------------------------------------- /src/vaultwarden/models/permissive_model.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseModel 2 | 3 | from vaultwarden.utils.string_cases import pascal_case_to_camel_case 4 | 5 | 6 | class PermissiveBaseModel( 7 | BaseModel, 8 | extra="allow", 9 | alias_generator=pascal_case_to_camel_case, 10 | populate_by_name=True, 11 | arbitrary_types_allowed=True, 12 | ): 13 | pass 14 | -------------------------------------------------------------------------------- /src/vaultwarden/models/sync.py: -------------------------------------------------------------------------------- 1 | import time 2 | from uuid import UUID 3 | 4 | from pydantic import AliasChoices, Field, field_validator 5 | 6 | from vaultwarden.models.enum import VaultwardenUserStatus 7 | from vaultwarden.models.permissive_model import PermissiveBaseModel 8 | from vaultwarden.utils.crypto import decrypt 9 | 10 | 11 | class ConnectToken(PermissiveBaseModel): 12 | Kdf: int = 0 13 | KdfIterations: int = 0 14 | KdfMemory: int | None = None 15 | KdfParallelism: int | None = None 16 | Key: str 17 | PrivateKey: str 18 | access_token: str 19 | refresh_token: str | None = None 20 | expires_in: int 21 | token_type: str 22 | scope: str 23 | unofficialServer: bool = False 24 | ResetMasterPassword: bool | None = None 25 | master_key: bytes | None = None 26 | 27 | @field_validator("expires_in") 28 | @classmethod 29 | def expires_in_to_time(cls, v): 30 | return time.time() + v 31 | 32 | def is_expired(self, now=None): 33 | if now is None: 34 | now = time.time() 35 | return (self.expires_in is not None) and (self.expires_in <= now) 36 | 37 | @property 38 | def user_key(self): 39 | return decrypt(self.Key, self.master_key) 40 | 41 | @property 42 | def orgs_key(self): 43 | return decrypt(self.PrivateKey, self.user_key) 44 | 45 | 46 | class ProfileOrganization(PermissiveBaseModel): 47 | Id: UUID 48 | Name: str 49 | Key: str | None = None 50 | ProviderId: str | None = None 51 | ProviderName: str | None = None 52 | ResetPasswordEnrolled: bool 53 | Seats: int | None = None 54 | SelfHost: bool 55 | SsoBound: bool 56 | Status: int 57 | Type: int 58 | Use2fa: bool 59 | UseApi: bool 60 | UseDirectory: bool 61 | UseEvents: bool 62 | UseGroups: bool 63 | UsePolicies: bool 64 | UseResetPassword: bool 65 | UseSso: bool 66 | UseTotp: bool 67 | 68 | 69 | class UserProfile(PermissiveBaseModel): 70 | AvatarColor: str | None 71 | Culture: str 72 | Email: str 73 | EmailVerified: bool 74 | ForcePasswordReset: bool 75 | Id: UUID 76 | Key: str 77 | MasterPasswordHint: str | None 78 | Name: str 79 | Object: str | None 80 | Organizations: list[ProfileOrganization] 81 | Premium: bool 82 | PrivateKey: str | None 83 | ProviderOrganizations: list 84 | Providers: list 85 | SecurityStamp: str 86 | TwoFactorEnabled: bool 87 | status: VaultwardenUserStatus = Field( 88 | validation_alias=AliasChoices("_status", "_Status") 89 | ) 90 | 91 | 92 | class VaultwardenUser(UserProfile): 93 | UserEnabled: bool 94 | CreatedAt: str 95 | LastActive: str | None = None 96 | 97 | 98 | # TODO: add definition of attribute's types 99 | class SyncData(PermissiveBaseModel): 100 | Ciphers: list[dict] 101 | Collections: list[dict] 102 | Domains: dict | None 103 | Folders: list[dict] 104 | Policies: list[dict] 105 | Profile: UserProfile 106 | Sends: list[dict] 107 | -------------------------------------------------------------------------------- /src/vaultwarden/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numberly/python-vaultwarden/964e13b708a9b3c4f8e7c6352db41506a88ecff1/src/vaultwarden/utils/__init__.py -------------------------------------------------------------------------------- /src/vaultwarden/utils/crypto.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # Original source: 4 | # https://github.com/corpusops/bitwardentools/blob/main/src/bitwardentools/crypto.py 5 | from __future__ import absolute_import, division, print_function 6 | 7 | import base64 8 | import hashlib 9 | import re 10 | import secrets 11 | import string 12 | from base64 import b64decode, b64encode 13 | from enum import IntEnum 14 | from hashlib import pbkdf2_hmac, sha256 15 | from hmac import new as hmac_new 16 | from secrets import token_bytes 17 | 18 | from Crypto.Cipher import AES, PKCS1_OAEP 19 | from Crypto.PublicKey import RSA 20 | from hkdf import hkdf_expand 21 | 22 | 23 | class CIPHERS(IntEnum): 24 | sym = 2 25 | asym = 4 26 | 27 | 28 | CACHE = {} # type: ignore 29 | ITERATIONS = 2000000 30 | ENCODED_CIPHER = { 31 | CIPHERS.sym: "{typ}.{b64_iv}|{b64_ct}|{b64_digest}", 32 | CIPHERS.asym: "{typ}.{b64_ct}", 33 | } 34 | ENCRYPTED_STRING_RE = re.compile("^[0-9][.].*=.*", flags=re.I | re.M) 35 | SYM_ENCRYPTED_STRING_RE = re.compile( 36 | "^2[.][^=]+=+[|][^=]+=+[|][^=]+=+", flags=re.I | re.M 37 | ) 38 | 39 | 40 | class UnimplementedError(Exception): 41 | """.""" 42 | 43 | 44 | class DecodeEncKeyError(ValueError): 45 | """.""" 46 | 47 | 48 | class WrongFormatError(DecodeEncKeyError): 49 | """.""" 50 | 51 | 52 | class WrongTypeDecryptError(DecodeEncKeyError): 53 | """.""" 54 | 55 | 56 | class MissingPartsDecryptError(DecodeEncKeyError): 57 | """.""" 58 | 59 | 60 | class B64DecryptError(DecodeEncKeyError): 61 | """.""" 62 | 63 | 64 | class DecryptError(ValueError): 65 | """.""" 66 | 67 | 68 | def decode_cipher_string(cipher_string): 69 | """decode a cipher tring into it's parts""" 70 | iv = None 71 | mac = None 72 | if not ENCRYPTED_STRING_RE.match(cipher_string): 73 | raise WrongFormatError(f"{cipher_string}") 74 | try: 75 | typ = cipher_string[0:1] 76 | typ = int(typ) 77 | assert typ < 9 78 | except (AssertionError, ValueError): 79 | raise WrongTypeDecryptError(f"{typ} is not valid") 80 | ct = cipher_string[2:] 81 | if typ == CIPHERS.asym: 82 | pass 83 | else: 84 | try: 85 | if typ == 0: 86 | iv, ct = ct.split("|", 2) 87 | else: 88 | iv, ct, mac = ct.split("|", 3) 89 | except Exception: 90 | raise MissingPartsDecryptError(f"{ct} is missing parts") 91 | if iv: 92 | try: 93 | iv = b64decode(iv) 94 | except Exception: 95 | raise B64DecryptError(f"iv {iv} not valid") 96 | if mac: 97 | try: 98 | mac = b64decode(mac)[0:32] 99 | except Exception: 100 | raise B64DecryptError(f"mac {mac} not valid") 101 | try: 102 | ct = b64decode(ct) 103 | except Exception: 104 | raise B64DecryptError(f"ct {ct} not valid") 105 | return typ, iv, ct, mac 106 | 107 | 108 | def is_encrypted(cipher_string): 109 | try: 110 | decode_cipher_string(cipher_string) 111 | except DecodeEncKeyError: 112 | return False 113 | else: 114 | return True 115 | 116 | 117 | def make_master_key(password, salt, iterations=ITERATIONS): 118 | salt = salt.lower() 119 | if not hasattr(password, "decode"): 120 | password = password.encode("utf-8") 121 | if not hasattr(salt, "decode"): 122 | salt = salt.encode("utf-8") 123 | return pbkdf2_hmac("sha256", password, salt, iterations) 124 | 125 | 126 | def hash_password(password, salt, iterations=ITERATIONS): 127 | """base64-encode a wrapped, stretched password+salt(email) for signup/login""" 128 | if not hasattr(password, "decode"): 129 | password = password.encode("utf-8") 130 | master_key = make_master_key(password, salt, iterations) 131 | hashpw = hashlib.pbkdf2_hmac("sha256", master_key, password, 1) 132 | return base64.b64encode(hashpw), master_key 133 | 134 | 135 | def load_rsa_key(key): 136 | rsakeys = CACHE.setdefault("rsa", {}) 137 | if not isinstance(key, RSA.RsaKey): 138 | try: 139 | key = rsakeys[key] 140 | except KeyError: 141 | rsakeys[key] = RSA.importKey(key) 142 | key = rsakeys[key] 143 | return key 144 | 145 | 146 | def aes_encrypt(plaintext, key, charset="utf-8"): 147 | enc, mac = get_sym_enc_mac(key) 148 | if not hasattr(plaintext, "decode"): 149 | plaintext = plaintext.encode(charset) 150 | pad_len = 16 - len(plaintext) % 16 151 | padding = bytes([pad_len] * pad_len) 152 | content = plaintext + padding 153 | iv = token_bytes(16) 154 | c = AES.new(enc, AES.MODE_CBC, iv) 155 | ct = c.encrypt(content) 156 | cmac = hmac_new(mac, iv + ct, sha256) 157 | return iv, ct, cmac 158 | 159 | 160 | def encrypt_sym(plaintext, key, to_bytes=False, *a, **kw): 161 | # inspired from bitwarden/jslib:src/services/crypto.service.ts 162 | typ, (iv, ct, mac) = int(CIPHERS.sym), aes_encrypt( 163 | plaintext, key, *a, **kw 164 | ) 165 | if mac: 166 | mac = mac.digest() 167 | if to_bytes: 168 | # jslib: encryptToBytes() 169 | ret = chr(typ).encode() 170 | ret += iv 171 | if mac: 172 | ret += mac 173 | ret += ct 174 | else: 175 | # jslib: encrypt() 176 | b64_iv = b64encode(iv).decode() 177 | b64_ct = b64encode(ct).decode() 178 | b64_digest = "" 179 | if mac: 180 | b64_digest = b64encode(mac).decode() 181 | ret = ENCODED_CIPHER[typ].format(**locals()) 182 | return ret 183 | 184 | 185 | def encrypt_sym_to_bytes(plaintext, key, *a, **kw): 186 | kw["to_bytes"] = True 187 | return encrypt_sym(plaintext, key, *a, **kw) 188 | 189 | 190 | def encrypt_asym(plaintext, key, *a, **kw): 191 | cipher = PKCS1_OAEP.new(load_rsa_key(key)).encrypt(plaintext) 192 | b64_ct = b64encode(cipher).decode() 193 | typ = CIPHERS.asym 194 | return ENCODED_CIPHER[typ].format(**locals()) 195 | 196 | 197 | def encrypt(typ, plaintext, key, *a, **kw): 198 | try: 199 | enc = ENCRYPT[typ] 200 | except KeyError: 201 | raise UnimplementedError(f"can not encrypt type:{typ}") 202 | return enc(plaintext=plaintext, key=key, *a, **kw) 203 | 204 | 205 | def get_sym_enc_mac(key): 206 | # symmetric master_key of the user 207 | if len(key) == 32: 208 | enc = hkdf_expand(key, b"enc", 32, sha256) 209 | mac = hkdf_expand(key, b"mac", 32, sha256) 210 | # symmetric key of an organization 211 | elif len(key) == 64: 212 | enc = key[:32] 213 | mac = key[32:] 214 | return enc, mac 215 | 216 | 217 | def decrypt_sym(dct, key, div, dmac, *a, **kw): 218 | enc, mac = get_sym_enc_mac(key) 219 | hdmac = hmac_new(mac, div + dct, sha256).digest() 220 | if hdmac != dmac: 221 | raise DecryptError( 222 | f"Symetric hmac verification failed {hdmac} / {dmac}" 223 | ) 224 | c = AES.new(enc, AES.MODE_CBC, div) 225 | plaintext = c.decrypt(dct) 226 | pad_len = plaintext[-1] 227 | padding = bytes([pad_len] * pad_len) 228 | if plaintext[-pad_len:] == padding: 229 | plaintext = plaintext[:-pad_len] 230 | return plaintext 231 | 232 | 233 | def decrypt_asym(dct, key, *a, **kw): 234 | return PKCS1_OAEP.new(load_rsa_key(key)).decrypt(dct) 235 | 236 | 237 | def decrypt_bytes(cipher_bytes, key, *a, **kw): 238 | ret, typ = None, cipher_bytes[0] 239 | if typ in [2]: 240 | iv = cipher_bytes[1:17] 241 | mac = cipher_bytes[17:49] 242 | ct = cipher_bytes[49:] 243 | ret = decrypt_sym(ct, key, iv, mac) 244 | else: 245 | raise UnimplementedError( 246 | f"{typ} encType decryption is not implemented" 247 | ) 248 | return ret 249 | 250 | 251 | def decrypt(cipher_string, key, *a, **kw): 252 | typ, iv, ct, mac = decode_cipher_string(cipher_string) 253 | try: 254 | dec = DECRYPT[typ] 255 | except KeyError: 256 | raise UnimplementedError(f"can not decrypt type:{typ}") 257 | return dec(div=iv, dct=ct, dmac=mac, key=key, *a, **kw) 258 | 259 | 260 | def strech_key(key): 261 | stretched_key = key 262 | if len(stretched_key) < 64: 263 | stretched_key = hkdf_expand(key, b"enc", 32, sha256) + hkdf_expand( 264 | key, b"mac", 32, sha256 265 | ) 266 | return stretched_key 267 | 268 | 269 | def make_sym_key(master_key): 270 | stretched_key = strech_key(master_key) 271 | plaintext = token_bytes(64) 272 | return encrypt_sym(plaintext, stretched_key), plaintext 273 | 274 | 275 | def make_asym_key(key, stretch=True): 276 | if stretch: 277 | key = strech_key(key) 278 | asym_key = RSA.generate(2048) 279 | public_key = asym_key.publickey().exportKey("DER") 280 | private_key = asym_key.exportKey("DER", pkcs=8) 281 | return encrypt_sym(private_key, key), public_key, private_key 282 | 283 | 284 | def gen_password(length=32, alphabet=None): 285 | alphabet = string.ascii_letters + string.digits 286 | while True: 287 | password = "".join(secrets.choice(alphabet) for i in range(length)) 288 | if ( 289 | any(c.islower() for c in password) 290 | and any(c.isupper() for c in password) 291 | and sum(c.isdigit() for c in password) >= 3 292 | ): 293 | break 294 | return password 295 | 296 | 297 | DECRYPT = {CIPHERS.sym: decrypt_sym, CIPHERS.asym: decrypt_asym} 298 | ENCRYPT = {CIPHERS.sym: encrypt_sym, CIPHERS.asym: encrypt_asym} 299 | # vim:set et sts=4 ts=4 tw=120: 300 | -------------------------------------------------------------------------------- /src/vaultwarden/utils/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logging.basicConfig() 4 | logger = logging.getLogger(__name__) 5 | 6 | 7 | def log_raise_for_status(response) -> None: 8 | if response.status_code == 403: 9 | logger.error( 10 | "Error: 403 Forbidden. Given Account has not access the data." 11 | ) 12 | if response.status_code >= 400: 13 | logger.error(f"Error: {response.status_code}") 14 | response.raise_for_status() 15 | -------------------------------------------------------------------------------- /src/vaultwarden/utils/string_cases.py: -------------------------------------------------------------------------------- 1 | def pascal_case_to_camel_case(pascal: str) -> str: 2 | """Convert a PascalCase string to camelCase. 3 | 4 | Args: 5 | pascal: The string to convert. 6 | 7 | Returns: 8 | The converted camelCase string. 9 | """ 10 | return pascal[0].lower() + pascal[1:] 11 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numberly/python-vaultwarden/964e13b708a9b3c4f8e7c6352db41506a88ecff1/tests/__init__.py -------------------------------------------------------------------------------- /tests/e2e/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numberly/python-vaultwarden/964e13b708a9b3c4f8e7c6352db41506a88ecff1/tests/e2e/__init__.py -------------------------------------------------------------------------------- /tests/e2e/run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ -z "${VAULTWARDEN_VERSION}" ]]; then 4 | VAULTWARDEN_VERSION="1.33.2" 5 | fi 6 | 7 | temp_dir=$(mktemp -d) 8 | 9 | # Copy fixtures db to tmp 10 | cp tests/fixtures/server/* $temp_dir 11 | 12 | # Start Vaultwarden docker 13 | docker run -d --name vaultwarden -v $temp_dir:/data --env I_REALLY_WANT_VOLATILE_STORAGE=true --env ADMIN_TOKEN=admin --restart unless-stopped -p 80:80 vaultwarden/server:${VAULTWARDEN_VERSION} 14 | 15 | #exit 0 16 | 17 | # Wait for vaultwarden to start 18 | sleep 3 19 | 20 | # Set env variables 21 | export VAULTWARDEN_URL="http://localhost:80" 22 | export VAULTWARDEN_ADMIN_TOKEN="admin" 23 | export BITWARDEN_URL="http://localhost:80" 24 | export BITWARDEN_EMAIL="test-account@example.com" 25 | export BITWARDEN_PASSWORD="test-account" 26 | export BITWARDEN_CLIENT_ID="user.a8be340c-856b-481f-8183-2b7712995da2" 27 | export BITWARDEN_CLIENT_SECRET="ag66paVUq4h7tBLbCbJOY5tJkQvUuT" 28 | export BITWARDEN_TEST_ORGANIZATION="cda840d2-1de0-4f31-bd49-b30dacd7e8b0" 29 | export BITWARDEN_DEVICE_ID="e54ba5f5-7d58-4830-8f2b-99194c70c14f" 30 | 31 | # Run tests 32 | hatch run test:with-coverage 33 | 34 | # store the exit code 35 | TEST_EXIT_CODE=$? 36 | 37 | # Stop and remove vaultwarden docker 38 | docker stop vaultwarden 39 | docker rm vaultwarden 40 | 41 | # Remove fixtures db from tmp 42 | rm -rf $temp_dir 43 | 44 | # Exit with the test exit code 45 | exit $TEST_EXIT_CODE -------------------------------------------------------------------------------- /tests/e2e/test_bitwarden.py: -------------------------------------------------------------------------------- 1 | import os 2 | import unittest 3 | 4 | from vaultwarden.clients.bitwarden import BitwardenAPIClient 5 | from vaultwarden.models.bitwarden import get_organization 6 | 7 | # Get Bitwarden credentials from environment variables 8 | url = os.environ.get("BITWARDEN_URL", None) 9 | email = os.environ.get("BITWARDEN_EMAIL", None) 10 | password = os.environ.get("BITWARDEN_PASSWORD", None) 11 | client_id = os.environ.get("BITWARDEN_CLIENT_ID", None) 12 | client_secret = os.environ.get("BITWARDEN_CLIENT_SECRET", None) 13 | device_id = os.environ.get("BITWARDEN_DEVICE_ID", None) 14 | bitwarden = BitwardenAPIClient( 15 | url, email, password, client_id, client_secret, device_id 16 | ) 17 | 18 | # Get test organization id from environment variables 19 | test_organization = os.environ.get("BITWARDEN_TEST_ORGANIZATION", None) 20 | 21 | 22 | class BitwardenBasic(unittest.TestCase): 23 | def setUp(self) -> None: 24 | self.organization = get_organization(bitwarden, test_organization) 25 | self.test_colls_names = self.organization.collections(as_dict=True) 26 | self.test_colls_ids = self.organization.collections() 27 | self.test_users = self.organization.users() 28 | self.test_org_ciphers = self.organization.ciphers() 29 | self.test_collection_1_ciphers = self.organization.ciphers( 30 | self.test_colls_names.get("test-collection").Id 31 | ) 32 | self.test_collection_2_ciphers = self.organization.ciphers( 33 | self.test_colls_names.get("test-collection-2").Id 34 | ) 35 | self.test_collection_1_users = self.test_colls_names.get( 36 | "test-collection" 37 | ).users() 38 | self.test_collection_2_users = self.test_colls_names.get( 39 | "test-collection-2" 40 | ).users() 41 | 42 | def test_get_organization_users(self): 43 | self.assertEqual(len(self.test_users), 2) 44 | 45 | def test_get_organization_items(self): 46 | self.assertEqual(len(self.test_org_ciphers), 1) 47 | 48 | def test_get_organization_collection_1_item(self): 49 | self.assertEqual(len(self.test_collection_1_ciphers), 0) 50 | 51 | def test_get_organization_collection_2_items(self): 52 | self.assertEqual(len(self.test_collection_2_ciphers), 1) 53 | 54 | def test_get_organizations_collections(self): 55 | # 2 test collections + default collection 56 | self.assertEqual(len(self.test_colls_ids), 3) 57 | 58 | def test_get_users_of_collection_1(self): 59 | # 2 test collections + default collection 60 | self.assertEqual(len(self.test_collection_1_users), 0) 61 | 62 | def test_get_users_of_collection_2(self): 63 | self.assertEqual(len(self.test_collection_2_users), 1) 64 | 65 | def test_create_delete_collection(self): 66 | len_old_colls = len(self.organization.collections(force_refresh=True)) 67 | new_coll = self.organization.create_collection("create_delete_test") 68 | new_colls = self.organization.collections(force_refresh=True) 69 | self.assertEqual(len(new_colls), len_old_colls + 1) 70 | self.organization.delete_collection(new_coll.Id) 71 | new_colls = self.organization.collections(force_refresh=True) 72 | self.assertEqual(len(new_colls), len_old_colls) 73 | 74 | def test_set_users_of_collection(self): 75 | coll = self.test_colls_names.get("test-collection") 76 | coll.set_users(self.test_collection_2_users) 77 | users = coll.users() 78 | self.assertEqual(len(users), 1) 79 | coll.set_users(self.test_collection_1_users) 80 | users = coll.users() 81 | self.assertEqual(len(users), 0) 82 | 83 | def test_add_remove_collection_from_user(self): 84 | user_org_id = self.test_collection_2_users[0].UserId 85 | user_infos = self.organization.user(user_org_id) 86 | collection_2 = self.test_colls_names.get("test-collection-2") 87 | user_infos.remove_collections([collection_2.Id]) 88 | self.assertEqual( 89 | len(collection_2.users()), 90 | 0, 91 | ) 92 | user_infos.add_collections([collection_2.Id]) 93 | users = collection_2.users() 94 | self.assertEqual( 95 | len(users), 96 | 1, 97 | ) 98 | 99 | def test_invite_user_than_remove(self): 100 | resp = self.organization.invite("test-user-3@example.com") 101 | self.assertTrue(resp.is_success) 102 | user = self.organization.user_search( 103 | "test-user-3@example.com", force_refresh=True 104 | ) 105 | self.assertIsNotNone(user) 106 | user.delete() 107 | 108 | def test_add_remove_collection_cipher(self): 109 | cipher = self.test_org_ciphers[0] 110 | old_colls = cipher.CollectionIds 111 | collection_1 = self.test_colls_ids[0] 112 | cipher.add_collections(collections=[collection_1.Id]) 113 | res = self.organization.ciphers(force_refresh=True) 114 | self.assertEqual(len(res), 1) 115 | self.assertEqual(len(res[0].CollectionIds), 2) 116 | cipher.update_collection(old_colls) 117 | 118 | def test_deduplicate(self): 119 | # Todo build test fixtures and delete them at the end of the test 120 | return 121 | 122 | 123 | if __name__ == "__main__": 124 | unittest.main() 125 | -------------------------------------------------------------------------------- /tests/e2e/test_vaultwarden.py: -------------------------------------------------------------------------------- 1 | # Unit test for VaultwardenAdminClient 2 | import os 3 | import unittest 4 | 5 | from vaultwarden.clients.vaultwarden import VaultwardenAdminClient 6 | 7 | # Get Vaultwarden Admin credentials from environment variables 8 | url = os.environ.get("VAULTWARDEN_URL", None) 9 | admin_token = os.environ.get("VAULTWARDEN_ADMIN_TOKEN", None) 10 | 11 | 12 | # TODO Add tests for VaultwardenAdminClient 13 | class VaultwardenAdminClientBasic(unittest.TestCase): 14 | def setUp(self) -> None: 15 | self.vaultwarden = VaultwardenAdminClient( 16 | url=url, admin_secret_token=admin_token 17 | ) 18 | -------------------------------------------------------------------------------- /tests/fixtures/admin/users_camel.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "_status": 0, 4 | "avatarColor": null, 5 | "createdAt": "2024-07-23 09:25:54 +00:00", 6 | "culture": "en-US", 7 | "email": "test-account@example.com", 8 | "emailVerified": true, 9 | "forcePasswordReset": false, 10 | "id": "a8be340c-856b-481f-8183-2b7712995da2", 11 | "key": "2.DTxwqo7MUUHE9e62TUO8aQ==|obupWKAMDnsQsTYsNw5vXRJromEdLoz86ApnaIK8xU1EdGX9MDfEmbLtDnS9lJbgiLn8m/lTCu/65sdm6Syv456y0k2xEahQr3jAbaaAXN8=|eHd5VPmgqxBf0sOGxmFMH2ESWnYKyiB6TgGx5SHZc1A=", 12 | "lastActive": "2024-07-23 12:15:19 +00:00", 13 | "masterPasswordHint": null, 14 | "name": "Test Account", 15 | "object": "profile", 16 | "organizations": [ 17 | { 18 | "accessSecretsManager": false, 19 | "allowAdminAccessToAllCollectionItems": true, 20 | "enabled": true, 21 | "familySponsorshipAvailable": false, 22 | "familySponsorshipFriendlyName": null, 23 | "familySponsorshipLastSyncDate": null, 24 | "familySponsorshipToDelete": null, 25 | "familySponsorshipValidUntil": null, 26 | "flexibleCollections": false, 27 | "hasPublicAndPrivateKeys": true, 28 | "id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 29 | "identifier": null, 30 | "key": "4.ZGlK4NPuK2AcLMbjv6V28lOeZapVjuE/NIMl3IEigeJ7OyCRu2OUfx/N91AzVxdM1XhBOqNbe+eUAN8HBYBb4UJSLcO/XVHOPjfjsYybBuPCCTyVue9Z/4xLZGfq6ggt2NOY29xAwvmufGYfXweRMkVXzdK9C3RGBjPbZ4WS5nm4blss5XCQs1SakXfe0J3Su+hlkRRbdz0NeAx7C+wasyNbdGTJQu+1F7JuJWoX2aBJYu/ulPnX61cYO+PVdXPSLpypp8mjdIRgu2I3xU1puFT0pU6V2e0XE9mIKJA6eqmXRwkbSO9ij+jwshz6RB4HueB2nqyYqIYPEJVNKceK4g==", 31 | "keyConnectorEnabled": false, 32 | "keyConnectorUrl": null, 33 | "limitCollectionCreationDeletion": true, 34 | "maxCollections": 10, 35 | "maxStorageGb": 10, 36 | "name": "Test Organization", 37 | "object": "profileOrganization", 38 | "permissions": { 39 | "accessEventLogs": false, 40 | "accessImportExport": false, 41 | "accessReports": false, 42 | "createNewCollections": false, 43 | "deleteAnyCollection": false, 44 | "deleteAssignedCollections": false, 45 | "editAnyCollection": false, 46 | "editAssignedCollections": false, 47 | "manageGroups": false, 48 | "managePolicies": false, 49 | "manageResetPassword": false, 50 | "manageScim": false, 51 | "manageSso": false, 52 | "manageUsers": false 53 | }, 54 | "planProductType": 0, 55 | "providerId": null, 56 | "providerName": null, 57 | "providerType": null, 58 | "resetPasswordEnrolled": false, 59 | "seats": 10, 60 | "selfHost": true, 61 | "ssoBound": false, 62 | "status": 2, 63 | "type": 0, 64 | "use2fa": true, 65 | "useActivateAutofillPolicy": false, 66 | "useApi": true, 67 | "useCustomPermissions": false, 68 | "useDirectory": false, 69 | "useEvents": false, 70 | "useGroups": false, 71 | "useKeyConnector": false, 72 | "usePasswordManager": true, 73 | "usePolicies": true, 74 | "useResetPassword": false, 75 | "useScim": false, 76 | "useSecretsManager": false, 77 | "useSso": false, 78 | "useTotp": true, 79 | "userId": "a8be340c-856b-481f-8183-2b7712995da2", 80 | "usersGetPremium": true 81 | } 82 | ], 83 | "premium": true, 84 | "premiumFromOrganization": false, 85 | "privateKey": "2.spAwCfq3v5MzYTt0zb++bQ==|YYEJ0FXRBCAySl2KAjgsGVreD3/mBnYvL49NCvKRXe//f4Cr8hQyXwvZqCYl2tgUAxy08AyCxE5V5sCTXyxKee2WgArxLRLQHsmvrmSjZwTE5RJd8hBwVVMw073mowf+UW+gK7bli12Yy0yHNfIrNeVKgSoGVAm0v71TzQgGwOcbxdfSu2ovP7HYIypQ+BFl2tXb+zu1IYbLPEvhRYJTHUILr3mtm4M6B9TRw4A9CgPgLBe0V/QWubLrgoBijRRCN38xSXY4rIEI3SovqIITUEF3B3QC+/235iRppgurhOmuMZOqvLhoZrizYmxvyQwSKC6erF/j0KY7ujyP9tYNVV614aGI3cH10mwntmKdPGMstmbOb4xcDZFRI6mclVxcXlGlSg0c8oOacXQwTQ6m0EwBLXvsLkPGt6n8qLGB1EfdoY9B367GX5vrpThhL0txinTcG0p2ISOsD1vGXm9nuPTZWfR1hjy+xUNCe1ay/3TGRysyggA4mL9NOKeNs2RRZU0jr7IlqV/QN7Cr+dGZ74KRq2hv8cVR0JCsXgxcwlzeqUY2jo2iTe/MsXWfToMqLBhkFCLSl3AkuLfGn+ftGkI5xxyG4y9HZungJwrBksxjUBJnLd8jzxxz2HYgRA/AXqpsTHiD9CU2gKAc8oKQMLy6HShVUCzLALmhOgxxdQUpROLzq2NdtTThqWLxdFkzLxOOBONaEA0LEuXGh6ooLsubj5RUC0fK84WsKShqdyjeZx/H0Eze2c2V39Aru9yQlMjpXSyKHFWGb9e3QAKdC37zX6ajka+qu3dAGQyELCUydD1lpPEt6+m/Qy5nUdkEphnqRx5ZvEtSnU+CMKmq4C7t4Kj/HF8AHLBmnvsozxQp+hmGVkF/JzdzXhUUHeQwNtP7YcgA4Z0FRjxb+pEqaHOjrYVXl0PDzRNc8VxwS5jvWv2Pu1Pu0aBUJYt/EAHicmUxZcCLHsjHTB5trRpT3ttorkrce5DDdBTpiF7NR87SKg+my6ohvzHzhkFXuvuHzy9Kh8KwOh44sInNyQOn7w+Yoja2O0i9NXN+esFlhDTIhKQ1KFfFQAJ3yeGgpRoLLSpxEzSoslyEIdmZbFPnlWwcsVToEOf3BdXgR8G2lFr1zL44WyBUtL2ESufxIVYcs5rc+VELFkRVaaUSQ8XHVYG81GZYcD3eXxRIHiJXEp91l36Toao8JJMW5kjmJy4uVuSZA+/pdnev7lISXP9+L+BcNU5udmQ1n2ZfvIqHLnPdnKbuyKjsaY2CwQt6bqBlo6/jHj8tCoD0ux26EPobUIY5kLVEhsKBrXO9NRdHF4kH6KkkJ6P3UBctm7s3UJ5PK9LT0ORJV5ssIdTiAny7oy8AaSx4xxJYZVYLbREzUy0elsCvAV31U0slAYlyeDMTdoXy4nOlYuWMsdWSsJMCcNCZoI9cU49Z2LFGZlJeNjUugPgHBpkSemMC7gwbIRnLG/klOrBzdK8wQ06N9Ee7uyh1i6eIq6eCro+t8T1bdWebPn9vITNKUW6Mx1tBeEsuGh1zIf8h2Oyp8RfosJJxm4SwFTrvNfocIntD9DCQ8FaUvANYnVNQVe0uII0C7LMpmNpZ53wX77ccgW82c0KJjdEqkivNbkvvZj0Dn6jeXZw=|vEnM4IsDD47rWIndjXlmmMqfzhAKa98iWwPeiln6S6s=", 86 | "providerOrganizations": [], 87 | "providers": [], 88 | "securityStamp": "f5bffd6f-bb08-4469-962a-3f96810bd56e", 89 | "twoFactorEnabled": false, 90 | "userEnabled": true, 91 | "usesKeyConnector": false 92 | }, 93 | { 94 | "_status": 0, 95 | "avatarColor": null, 96 | "createdAt": "2024-07-23 09:27:39 +00:00", 97 | "culture": "en-US", 98 | "email": "test-account-2@example.com", 99 | "emailVerified": true, 100 | "forcePasswordReset": false, 101 | "id": "cd95d118-e96d-4b8d-a000-a10c92dd8f88", 102 | "key": "2.Y2xq0VALTE95WfqukeGjRA==|ycjbWhJ+LCSRmQyjil6CY6ylkHUtb4rIjIUjiaDSNZTIhwUpDBewINyou2HsBmr/JRj4bljVLcwYK/LzeCcstizhUf9KzveYkPiTfvBNzmk=|3CLBCSMdLRElzR0h+wm8JvxiYkkoHS9WO3MHpRMMAc4=", 103 | "lastActive": "2024-07-23 12:36:20 +00:00", 104 | "masterPasswordHint": null, 105 | "name": "Test Account 2", 106 | "object": "profile", 107 | "organizations": [ 108 | { 109 | "accessSecretsManager": false, 110 | "allowAdminAccessToAllCollectionItems": true, 111 | "enabled": true, 112 | "familySponsorshipAvailable": false, 113 | "familySponsorshipFriendlyName": null, 114 | "familySponsorshipLastSyncDate": null, 115 | "familySponsorshipToDelete": null, 116 | "familySponsorshipValidUntil": null, 117 | "flexibleCollections": false, 118 | "hasPublicAndPrivateKeys": true, 119 | "id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 120 | "identifier": null, 121 | "key": "4.Oc8mQiv88uC4GuG9cPiCW7fpWiXAJ0Q1R1QvEuXjhpKsGA405FOTAvH9DpWZDrta3KG07ek273j7c7+z7g9VC0a+N7DS52DL29vIRz5sE8gDDxlK5vBVJz5tU8lrJiObBz93nYr0U3ujmcL4VTbchlrNAtz2Cp3LtlEQGKzT2isGZZm3GpCriZvls9IaapXRTXMDS0YlTo39zNSeR0xNe3kMAnM5fbiNe5RxFGdxwISOHczdPIF4e/k4n1+TTbmrQ1SieQIASgfCdCjRDhQdexMaoafKDgfjZBwwLn7d9kL2D/8ni9AhOxJzpsn3O3tgW2m+kWu+8ytGP9YE6jwMUw==", 122 | "keyConnectorEnabled": false, 123 | "keyConnectorUrl": null, 124 | "limitCollectionCreationDeletion": true, 125 | "maxCollections": 10, 126 | "maxStorageGb": 10, 127 | "name": "Test Organization", 128 | "object": "profileOrganization", 129 | "permissions": { 130 | "accessEventLogs": false, 131 | "accessImportExport": false, 132 | "accessReports": false, 133 | "createNewCollections": false, 134 | "deleteAnyCollection": false, 135 | "deleteAssignedCollections": false, 136 | "editAnyCollection": false, 137 | "editAssignedCollections": false, 138 | "manageGroups": false, 139 | "managePolicies": false, 140 | "manageResetPassword": false, 141 | "manageScim": false, 142 | "manageSso": false, 143 | "manageUsers": false 144 | }, 145 | "planProductType": 0, 146 | "providerId": null, 147 | "providerName": null, 148 | "providerType": null, 149 | "resetPasswordEnrolled": false, 150 | "seats": 10, 151 | "selfHost": true, 152 | "ssoBound": false, 153 | "status": 2, 154 | "type": 2, 155 | "use2fa": true, 156 | "useActivateAutofillPolicy": false, 157 | "useApi": true, 158 | "useCustomPermissions": false, 159 | "useDirectory": false, 160 | "useEvents": false, 161 | "useGroups": false, 162 | "useKeyConnector": false, 163 | "usePasswordManager": true, 164 | "usePolicies": true, 165 | "useResetPassword": false, 166 | "useScim": false, 167 | "useSecretsManager": false, 168 | "useSso": false, 169 | "useTotp": true, 170 | "userId": "cd95d118-e96d-4b8d-a000-a10c92dd8f88", 171 | "usersGetPremium": true 172 | } 173 | ], 174 | "premium": true, 175 | "premiumFromOrganization": false, 176 | "privateKey": "2.jwhyVLmpbVAdnDWAzWcC2A==|uK3ZVxUL1h23PuIMFwRF04TMLrwMph5eQaiof22jvvvSMr0lK96yoZgZ16Iwod62csJps0PLzPRTywfO8M3yZTzD/zVIY26NKc5fCdRotXFjNzt4AdGeBioLA5c3EzOlmD3Jc3Eefcu1tPR+j2HuuJLsaGlSrQ3SRn3JJTBrLavddApw/PS8yb4uz5NoE3U9gnMvD+Uf9SzGhiDlBMHWlFGQ1CZKtKNEY5HOginiOFHoswveMFtUZgxioYXzSqSWES9k1LSbrUZNBNqLHZhEbXAupYpD6peUe+KIFx0vNIiXzRt5vnuOEYku9eeCfPugRrVtH/FuTJEAvkz9Kbb0XR1u4YEMRi8k5b9bmwqE6EwYcIJ9Djg8XO6psP5M5Wz3ForPKRWYnRmkGS4MKjCX4JtnrNmEKGx5Gzw1YNiBwYkY6tA8lNMGKLqW9qufE2vGmkvF8cq3cG6QOd3nzUCcxmjAZuDo8ZWd7axv1y4J0TUqNQQQ2Bnd+ZMcORYUafV10fZ5AIKisdWhOw4HJXUcDWGXXmeftuA9kkUN1FZZI2bdYfDpBOzw9WBt4vGNbU2Uw/Px6u6DzwbEa+Pd4LTJem6oIyFhy/mNqZWjPyX46J0FHTPjqFGFwExvoBcCKPG6BDaZb3y22kxZr9Ss7LbV6Tax1JxA4I0elaX5CgrIozh/nji7f7oTdYljWYGA7Ts3Eb2mL1j+az1UHwi0qDVe1v8E4CBxZyNBw4JbuFQ1eTys6DOmkGPw00sngF0o1wFxgcRN9UK1DlmheF3omKwT42G8KAYPuPawDGZEtNOa9xoGVgVOXmKI4x+xFNenHm6oNd5WGrXDq7FCkkho32KmESmZhFxTaILJ4WrKOHUUDQhZ75K/jd67rQuvq0MbAD74+sxpQlosvuWtDWW9ceTRa0uEWrpHwB8vc9BbSqUwgdP03J38R/siNft06eBWtFktCQOQEZRv5VA+QSf5KPeH+0QNV2UtzpyiI7ce7mQlhXHvKXgf+p+QKN2U6nMH07KH1KlSQGTx58p/yEuReEDqht7/OCD9oQgUMtnY5gm3g+J4orz5tMtbV1RUSaeMUH+DN4gOgZlGFFw+gBVr5SLa1eIkdVpg86CdGUpODOJsnNGkFieQ+SEuUgZC1smPw270JVfDIwZ7jXplErw85zURY32tty8Lb1YaOkvIpyPx9ylMATpD1QkwlcUSoS6M9kiCeZGUWrTPDpmFI8fav79q3+X8xrZrQ3xCLKCii+d+Mban4M+liXLBGaZowqzWxv2d6EmxnJVzhJZqFMxcmOeCdwsgwbxUD6Ycd7fN/7rDBrIKOMiF3x/xlIpVLa3aA83dSQKsbkxVpjwS05fn53E96ZQaRX9avXRhIfsG3sD3TDvBU2disAi4wDszA3VgkLsxo9HZyiBdXVbzrdC97FqsIH49bmwBpj38pOhtkYu+JlXdXeKA9m1UIrKfgXY94dkEgO/qQnttZW6OmdfqFfJWx3qEv6/UoUxHoSdFlKDndkQIHfXQT3IlK8eHpUt0VdXs9JSkhcBsIZ6N/L2TN1kPhBMUr8W0eYu7yv9q/olSkCbF9NqyraFwvJP2IGr4WepOg4hn0lM2yVc1xzIXWqKNPaWj4AgTDzjqFQR8wPaHSC4=|anAl2GmUHBH7LaStnTMYYz3fPuqJ/obAyLb7waj5b8o=", 177 | "providerOrganizations": [], 178 | "providers": [], 179 | "securityStamp": "89c314b3-6645-4adb-a1c6-e470a977e6e4", 180 | "twoFactorEnabled": false, 181 | "userEnabled": true, 182 | "usesKeyConnector": false 183 | } 184 | ] -------------------------------------------------------------------------------- /tests/fixtures/admin/users_pascal.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "AvatarColor": null, 4 | "CreatedAt": "2024-07-23 09:25:54 +00:00", 5 | "Culture": "en-US", 6 | "Email": "test-account@example.com", 7 | "EmailVerified": true, 8 | "ForcePasswordReset": false, 9 | "Id": "a8be340c-856b-481f-8183-2b7712995da2", 10 | "Key": "2.DTxwqo7MUUHE9e62TUO8aQ==|obupWKAMDnsQsTYsNw5vXRJromEdLoz86ApnaIK8xU1EdGX9MDfEmbLtDnS9lJbgiLn8m/lTCu/65sdm6Syv456y0k2xEahQr3jAbaaAXN8=|eHd5VPmgqxBf0sOGxmFMH2ESWnYKyiB6TgGx5SHZc1A=", 11 | "LastActive": "2024-07-23 13:14:28 +00:00", 12 | "MasterPasswordHint": null, 13 | "Name": "Test Account", 14 | "Object": "profile", 15 | "Organizations": [ 16 | { 17 | "Enabled": true, 18 | "HasPublicAndPrivateKeys": true, 19 | "Id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 20 | "Identifier": null, 21 | "Key": "4.ZGlK4NPuK2AcLMbjv6V28lOeZapVjuE/NIMl3IEigeJ7OyCRu2OUfx/N91AzVxdM1XhBOqNbe+eUAN8HBYBb4UJSLcO/XVHOPjfjsYybBuPCCTyVue9Z/4xLZGfq6ggt2NOY29xAwvmufGYfXweRMkVXzdK9C3RGBjPbZ4WS5nm4blss5XCQs1SakXfe0J3Su+hlkRRbdz0NeAx7C+wasyNbdGTJQu+1F7JuJWoX2aBJYu/ulPnX61cYO+PVdXPSLpypp8mjdIRgu2I3xU1puFT0pU6V2e0XE9mIKJA6eqmXRwkbSO9ij+jwshz6RB4HueB2nqyYqIYPEJVNKceK4g==", 22 | "MaxCollections": 10, 23 | "MaxStorageGb": 10, 24 | "Name": "Test Organization", 25 | "Object": "profileOrganization", 26 | "ProviderId": null, 27 | "ProviderName": null, 28 | "ResetPasswordEnrolled": false, 29 | "Seats": 10, 30 | "SelfHost": true, 31 | "SsoBound": false, 32 | "Status": 2, 33 | "Type": 0, 34 | "Use2fa": true, 35 | "UseApi": true, 36 | "UseDirectory": false, 37 | "UseEvents": false, 38 | "UseGroups": false, 39 | "UsePolicies": true, 40 | "UseResetPassword": false, 41 | "UseSso": false, 42 | "UseTotp": true, 43 | "UserId": "a8be340c-856b-481f-8183-2b7712995da2", 44 | "UsersGetPremium": true 45 | } 46 | ], 47 | "Premium": true, 48 | "PrivateKey": "2.spAwCfq3v5MzYTt0zb++bQ==|YYEJ0FXRBCAySl2KAjgsGVreD3/mBnYvL49NCvKRXe//f4Cr8hQyXwvZqCYl2tgUAxy08AyCxE5V5sCTXyxKee2WgArxLRLQHsmvrmSjZwTE5RJd8hBwVVMw073mowf+UW+gK7bli12Yy0yHNfIrNeVKgSoGVAm0v71TzQgGwOcbxdfSu2ovP7HYIypQ+BFl2tXb+zu1IYbLPEvhRYJTHUILr3mtm4M6B9TRw4A9CgPgLBe0V/QWubLrgoBijRRCN38xSXY4rIEI3SovqIITUEF3B3QC+/235iRppgurhOmuMZOqvLhoZrizYmxvyQwSKC6erF/j0KY7ujyP9tYNVV614aGI3cH10mwntmKdPGMstmbOb4xcDZFRI6mclVxcXlGlSg0c8oOacXQwTQ6m0EwBLXvsLkPGt6n8qLGB1EfdoY9B367GX5vrpThhL0txinTcG0p2ISOsD1vGXm9nuPTZWfR1hjy+xUNCe1ay/3TGRysyggA4mL9NOKeNs2RRZU0jr7IlqV/QN7Cr+dGZ74KRq2hv8cVR0JCsXgxcwlzeqUY2jo2iTe/MsXWfToMqLBhkFCLSl3AkuLfGn+ftGkI5xxyG4y9HZungJwrBksxjUBJnLd8jzxxz2HYgRA/AXqpsTHiD9CU2gKAc8oKQMLy6HShVUCzLALmhOgxxdQUpROLzq2NdtTThqWLxdFkzLxOOBONaEA0LEuXGh6ooLsubj5RUC0fK84WsKShqdyjeZx/H0Eze2c2V39Aru9yQlMjpXSyKHFWGb9e3QAKdC37zX6ajka+qu3dAGQyELCUydD1lpPEt6+m/Qy5nUdkEphnqRx5ZvEtSnU+CMKmq4C7t4Kj/HF8AHLBmnvsozxQp+hmGVkF/JzdzXhUUHeQwNtP7YcgA4Z0FRjxb+pEqaHOjrYVXl0PDzRNc8VxwS5jvWv2Pu1Pu0aBUJYt/EAHicmUxZcCLHsjHTB5trRpT3ttorkrce5DDdBTpiF7NR87SKg+my6ohvzHzhkFXuvuHzy9Kh8KwOh44sInNyQOn7w+Yoja2O0i9NXN+esFlhDTIhKQ1KFfFQAJ3yeGgpRoLLSpxEzSoslyEIdmZbFPnlWwcsVToEOf3BdXgR8G2lFr1zL44WyBUtL2ESufxIVYcs5rc+VELFkRVaaUSQ8XHVYG81GZYcD3eXxRIHiJXEp91l36Toao8JJMW5kjmJy4uVuSZA+/pdnev7lISXP9+L+BcNU5udmQ1n2ZfvIqHLnPdnKbuyKjsaY2CwQt6bqBlo6/jHj8tCoD0ux26EPobUIY5kLVEhsKBrXO9NRdHF4kH6KkkJ6P3UBctm7s3UJ5PK9LT0ORJV5ssIdTiAny7oy8AaSx4xxJYZVYLbREzUy0elsCvAV31U0slAYlyeDMTdoXy4nOlYuWMsdWSsJMCcNCZoI9cU49Z2LFGZlJeNjUugPgHBpkSemMC7gwbIRnLG/klOrBzdK8wQ06N9Ee7uyh1i6eIq6eCro+t8T1bdWebPn9vITNKUW6Mx1tBeEsuGh1zIf8h2Oyp8RfosJJxm4SwFTrvNfocIntD9DCQ8FaUvANYnVNQVe0uII0C7LMpmNpZ53wX77ccgW82c0KJjdEqkivNbkvvZj0Dn6jeXZw=|vEnM4IsDD47rWIndjXlmmMqfzhAKa98iWwPeiln6S6s=", 49 | "ProviderOrganizations": [], 50 | "Providers": [], 51 | "SecurityStamp": "f5bffd6f-bb08-4469-962a-3f96810bd56e", 52 | "TwoFactorEnabled": false, 53 | "UserEnabled": true, 54 | "_Status": 0 55 | }, 56 | { 57 | "AvatarColor": null, 58 | "CreatedAt": "2024-07-23 09:27:39 +00:00", 59 | "Culture": "en-US", 60 | "Email": "test-account-2@example.com", 61 | "EmailVerified": true, 62 | "ForcePasswordReset": false, 63 | "Id": "cd95d118-e96d-4b8d-a000-a10c92dd8f88", 64 | "Key": "2.Y2xq0VALTE95WfqukeGjRA==|ycjbWhJ+LCSRmQyjil6CY6ylkHUtb4rIjIUjiaDSNZTIhwUpDBewINyou2HsBmr/JRj4bljVLcwYK/LzeCcstizhUf9KzveYkPiTfvBNzmk=|3CLBCSMdLRElzR0h+wm8JvxiYkkoHS9WO3MHpRMMAc4=", 65 | "LastActive": "2024-07-23 12:36:20 +00:00", 66 | "MasterPasswordHint": null, 67 | "Name": "Test Account 2", 68 | "Object": "profile", 69 | "Organizations": [ 70 | { 71 | "Enabled": true, 72 | "HasPublicAndPrivateKeys": true, 73 | "Id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 74 | "Identifier": null, 75 | "Key": "4.Oc8mQiv88uC4GuG9cPiCW7fpWiXAJ0Q1R1QvEuXjhpKsGA405FOTAvH9DpWZDrta3KG07ek273j7c7+z7g9VC0a+N7DS52DL29vIRz5sE8gDDxlK5vBVJz5tU8lrJiObBz93nYr0U3ujmcL4VTbchlrNAtz2Cp3LtlEQGKzT2isGZZm3GpCriZvls9IaapXRTXMDS0YlTo39zNSeR0xNe3kMAnM5fbiNe5RxFGdxwISOHczdPIF4e/k4n1+TTbmrQ1SieQIASgfCdCjRDhQdexMaoafKDgfjZBwwLn7d9kL2D/8ni9AhOxJzpsn3O3tgW2m+kWu+8ytGP9YE6jwMUw==", 76 | "MaxCollections": 10, 77 | "MaxStorageGb": 10, 78 | "Name": "Test Organization", 79 | "Object": "profileOrganization", 80 | "ProviderId": null, 81 | "ProviderName": null, 82 | "ResetPasswordEnrolled": false, 83 | "Seats": 10, 84 | "SelfHost": true, 85 | "SsoBound": false, 86 | "Status": 2, 87 | "Type": 2, 88 | "Use2fa": true, 89 | "UseApi": true, 90 | "UseDirectory": false, 91 | "UseEvents": false, 92 | "UseGroups": false, 93 | "UsePolicies": true, 94 | "UseResetPassword": false, 95 | "UseSso": false, 96 | "UseTotp": true, 97 | "UserId": "cd95d118-e96d-4b8d-a000-a10c92dd8f88", 98 | "UsersGetPremium": true 99 | } 100 | ], 101 | "Premium": true, 102 | "PrivateKey": "2.jwhyVLmpbVAdnDWAzWcC2A==|uK3ZVxUL1h23PuIMFwRF04TMLrwMph5eQaiof22jvvvSMr0lK96yoZgZ16Iwod62csJps0PLzPRTywfO8M3yZTzD/zVIY26NKc5fCdRotXFjNzt4AdGeBioLA5c3EzOlmD3Jc3Eefcu1tPR+j2HuuJLsaGlSrQ3SRn3JJTBrLavddApw/PS8yb4uz5NoE3U9gnMvD+Uf9SzGhiDlBMHWlFGQ1CZKtKNEY5HOginiOFHoswveMFtUZgxioYXzSqSWES9k1LSbrUZNBNqLHZhEbXAupYpD6peUe+KIFx0vNIiXzRt5vnuOEYku9eeCfPugRrVtH/FuTJEAvkz9Kbb0XR1u4YEMRi8k5b9bmwqE6EwYcIJ9Djg8XO6psP5M5Wz3ForPKRWYnRmkGS4MKjCX4JtnrNmEKGx5Gzw1YNiBwYkY6tA8lNMGKLqW9qufE2vGmkvF8cq3cG6QOd3nzUCcxmjAZuDo8ZWd7axv1y4J0TUqNQQQ2Bnd+ZMcORYUafV10fZ5AIKisdWhOw4HJXUcDWGXXmeftuA9kkUN1FZZI2bdYfDpBOzw9WBt4vGNbU2Uw/Px6u6DzwbEa+Pd4LTJem6oIyFhy/mNqZWjPyX46J0FHTPjqFGFwExvoBcCKPG6BDaZb3y22kxZr9Ss7LbV6Tax1JxA4I0elaX5CgrIozh/nji7f7oTdYljWYGA7Ts3Eb2mL1j+az1UHwi0qDVe1v8E4CBxZyNBw4JbuFQ1eTys6DOmkGPw00sngF0o1wFxgcRN9UK1DlmheF3omKwT42G8KAYPuPawDGZEtNOa9xoGVgVOXmKI4x+xFNenHm6oNd5WGrXDq7FCkkho32KmESmZhFxTaILJ4WrKOHUUDQhZ75K/jd67rQuvq0MbAD74+sxpQlosvuWtDWW9ceTRa0uEWrpHwB8vc9BbSqUwgdP03J38R/siNft06eBWtFktCQOQEZRv5VA+QSf5KPeH+0QNV2UtzpyiI7ce7mQlhXHvKXgf+p+QKN2U6nMH07KH1KlSQGTx58p/yEuReEDqht7/OCD9oQgUMtnY5gm3g+J4orz5tMtbV1RUSaeMUH+DN4gOgZlGFFw+gBVr5SLa1eIkdVpg86CdGUpODOJsnNGkFieQ+SEuUgZC1smPw270JVfDIwZ7jXplErw85zURY32tty8Lb1YaOkvIpyPx9ylMATpD1QkwlcUSoS6M9kiCeZGUWrTPDpmFI8fav79q3+X8xrZrQ3xCLKCii+d+Mban4M+liXLBGaZowqzWxv2d6EmxnJVzhJZqFMxcmOeCdwsgwbxUD6Ycd7fN/7rDBrIKOMiF3x/xlIpVLa3aA83dSQKsbkxVpjwS05fn53E96ZQaRX9avXRhIfsG3sD3TDvBU2disAi4wDszA3VgkLsxo9HZyiBdXVbzrdC97FqsIH49bmwBpj38pOhtkYu+JlXdXeKA9m1UIrKfgXY94dkEgO/qQnttZW6OmdfqFfJWx3qEv6/UoUxHoSdFlKDndkQIHfXQT3IlK8eHpUt0VdXs9JSkhcBsIZ6N/L2TN1kPhBMUr8W0eYu7yv9q/olSkCbF9NqyraFwvJP2IGr4WepOg4hn0lM2yVc1xzIXWqKNPaWj4AgTDzjqFQR8wPaHSC4=|anAl2GmUHBH7LaStnTMYYz3fPuqJ/obAyLb7waj5b8o=", 103 | "ProviderOrganizations": [], 104 | "Providers": [], 105 | "SecurityStamp": "89c314b3-6645-4adb-a1c6-e470a977e6e4", 106 | "TwoFactorEnabled": false, 107 | "UserEnabled": true, 108 | "_Status": 0 109 | } 110 | ] -------------------------------------------------------------------------------- /tests/fixtures/server/db.sqlite3: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c8c11a331ba097f1644b297885cd09b4ac5fc975ed5605176c880bc5cf08a813 3 | size 245760 4 | -------------------------------------------------------------------------------- /tests/fixtures/server/rsa_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEogIBAAKCAQEA7isZJB3F8nXG0GkrlzxA42Smm+ZqB+Ev57AbhXWtqQnjJHp9 3 | sjtITsB7PkLt2w6eRR+dzWtTAtqVpVHyqp9MsvUc0239g8QEaW19fmhPrctRmFCT 4 | q9xNPTfxg4AHeCWHXu1a0ajIuB28ad+eeTNdXT2WB77H/FOltE5rkDMDGbj8tTfs 5 | tb4uEsPifUZZKjFxWmlKSb8Tg9rr1C+BhJRBkLbhGLXkEeZNDwlPBg/sTY6NmNhw 6 | bzV+fx8MBto6+Q6TL0Fo/sjHMR+bbbh6g9lp4X7dDz7jOqxXvbkEIMclSABH6GSl 7 | dwyr5/qQmLAGeUiXzgy28hVS9EzoDDVxt5G5hQIDAQABAoIBAC8GBF88n6YY+emR 8 | MkGYbGlZKIoUaq/mlqpEe5KUovaClL3Rj3q+uK6P02V+Gm9LShV0whfaTlf8Z1pu 9 | PR7R9/dHbOsTxt+atpJIQ2RPXRf/0jrkAdwHUZq6Lm2bvB3NLxaff3RwwjyT5mzy 10 | 8VuVuCPeMn6R/PNFYqygZR1h7QVJPtpz+S0EjWntCOytuHq556QSBpecAzKp87C3 11 | PNO7PCGp+WbTsUUTVFqkMiIyCrl8szvKKZp19ZemQTzRBsoiBYmCsnMKtAC2Xjkh 12 | wWOwSEDKdRzEtoWStxDQWCRlnco+UAOyCsI7cM8HB95u9ILcp0KKEnr1SWHR1ynU 13 | SUhmoYsCgYEA+12A6JZElV0h5HEvm5jvguPlwCehTKonUtmG7iinzR8l/AIZxyus 14 | bwxPSZJ21xRCV4m4FmnP6UD9ZYYbOAvHAxlIsJ/7hhYwLAsg7GvxHIIpdT6EDkS4 15 | vYdfhOmviOpS2g7phY+LrL8NewMST8f9/MDu2ygEgaUi7YhUlMeWgb8CgYEA8o9N 16 | dDivh7SLsD2s7jVXcxuZ7qo4jIC1XHwtqg/wxUPK8OI9Gzts7p7GZBegdszAjwof 17 | e7YhI0rbF3XekL+AkXNHq6n9Qp7SDnsxvoRK8sS0YeKtfdCVhmC9SkwO/bKt1F89 18 | 9k1epnUMuLomwtqJ4jOzEmxckLYMWg96W6IFzbsCgYAHAOnwkQ9EIh4poUW0TiSO 19 | Pw9NtUz3N950nn7178gNHQsP5HcXZ44cYflrkVsiTvwyODIa3cPfOeJVi9ECVMGs 20 | wm2WDj8R01hwQbcfHzrOkonZLG69fwiurzDoISK06+J3FOdIw2Ee5QvZG5LNCkN3 21 | YWDGVm0Zt6IrgBrrMkxtPQKBgH6iMBa4LXPU34TQfkMS2CgBRfkjJ0i7PXQeZJy/ 22 | m7zxKrdd9fcMrE9b10mUSDMdrH5BE7S7nktVnlJ+OAcr44yMOeO2aMFqN1JWIN9N 23 | I+/goCfmdxsTVa0FPm3WjZEHwtb4LlozhHG09EJQ9UGPZKMSyK+aoSzvzj0KjZ/f 24 | U9ZXAoGAX6AKx9IeilNR1mZm7BaYPbdIWMM+C+dCat8zFkGBfgMPmRlskuValn6U 25 | Xqzb05DAInWpdkh670sH9kfiKync02XgaIQ4Z1JLEpEH/OuGYQPgfbOFCYjDzrIV 26 | JLtL+m0BAFsI6bZUeuD2bi4b8nLuXeMVya+qxnjCvYdEqc7RANc= 27 | -----END RSA PRIVATE KEY----- -------------------------------------------------------------------------------- /tests/fixtures/test-account-2/organization_profile_camel.json: -------------------------------------------------------------------------------- 1 | { 2 | "accessSecretsManager": false, 3 | "allowAdminAccessToAllCollectionItems": true, 4 | "enabled": true, 5 | "familySponsorshipAvailable": false, 6 | "familySponsorshipFriendlyName": null, 7 | "familySponsorshipLastSyncDate": null, 8 | "familySponsorshipToDelete": null, 9 | "familySponsorshipValidUntil": null, 10 | "flexibleCollections": false, 11 | "hasPublicAndPrivateKeys": true, 12 | "id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 13 | "identifier": null, 14 | "key": "4.Oc8mQiv88uC4GuG9cPiCW7fpWiXAJ0Q1R1QvEuXjhpKsGA405FOTAvH9DpWZDrta3KG07ek273j7c7+z7g9VC0a+N7DS52DL29vIRz5sE8gDDxlK5vBVJz5tU8lrJiObBz93nYr0U3ujmcL4VTbchlrNAtz2Cp3LtlEQGKzT2isGZZm3GpCriZvls9IaapXRTXMDS0YlTo39zNSeR0xNe3kMAnM5fbiNe5RxFGdxwISOHczdPIF4e/k4n1+TTbmrQ1SieQIASgfCdCjRDhQdexMaoafKDgfjZBwwLn7d9kL2D/8ni9AhOxJzpsn3O3tgW2m+kWu+8ytGP9YE6jwMUw==", 15 | "keyConnectorEnabled": false, 16 | "keyConnectorUrl": null, 17 | "limitCollectionCreationDeletion": true, 18 | "maxCollections": 10, 19 | "maxStorageGb": 10, 20 | "name": "Test Organization", 21 | "object": "profileOrganization", 22 | "permissions": { 23 | "accessEventLogs": false, 24 | "accessImportExport": false, 25 | "accessReports": false, 26 | "createNewCollections": false, 27 | "deleteAnyCollection": false, 28 | "deleteAssignedCollections": false, 29 | "editAnyCollection": false, 30 | "editAssignedCollections": false, 31 | "manageGroups": false, 32 | "managePolicies": false, 33 | "manageResetPassword": false, 34 | "manageScim": false, 35 | "manageSso": false, 36 | "manageUsers": false 37 | }, 38 | "planProductType": 0, 39 | "providerId": null, 40 | "providerName": null, 41 | "providerType": null, 42 | "resetPasswordEnrolled": false, 43 | "seats": 10, 44 | "selfHost": true, 45 | "ssoBound": false, 46 | "status": 2, 47 | "type": 2, 48 | "use2fa": true, 49 | "useActivateAutofillPolicy": false, 50 | "useApi": true, 51 | "useCustomPermissions": false, 52 | "useDirectory": false, 53 | "useEvents": false, 54 | "useGroups": false, 55 | "useKeyConnector": false, 56 | "usePasswordManager": true, 57 | "usePolicies": true, 58 | "useResetPassword": false, 59 | "useScim": false, 60 | "useSecretsManager": false, 61 | "useSso": false, 62 | "useTotp": true, 63 | "userId": "cd95d118-e96d-4b8d-a000-a10c92dd8f88", 64 | "usersGetPremium": true 65 | } -------------------------------------------------------------------------------- /tests/fixtures/test-account-2/profile_camel.json: -------------------------------------------------------------------------------- 1 | { 2 | "_status": 0, 3 | "avatarColor": null, 4 | "culture": "en-US", 5 | "email": "test-account-2@example.com", 6 | "emailVerified": true, 7 | "forcePasswordReset": false, 8 | "id": "cd95d118-e96d-4b8d-a000-a10c92dd8f88", 9 | "key": "2.Y2xq0VALTE95WfqukeGjRA==|ycjbWhJ+LCSRmQyjil6CY6ylkHUtb4rIjIUjiaDSNZTIhwUpDBewINyou2HsBmr/JRj4bljVLcwYK/LzeCcstizhUf9KzveYkPiTfvBNzmk=|3CLBCSMdLRElzR0h+wm8JvxiYkkoHS9WO3MHpRMMAc4=", 10 | "masterPasswordHint": null, 11 | "name": "Test Account 2", 12 | "object": "profile", 13 | "organizations": [ 14 | { 15 | "accessSecretsManager": false, 16 | "allowAdminAccessToAllCollectionItems": true, 17 | "enabled": true, 18 | "familySponsorshipAvailable": false, 19 | "familySponsorshipFriendlyName": null, 20 | "familySponsorshipLastSyncDate": null, 21 | "familySponsorshipToDelete": null, 22 | "familySponsorshipValidUntil": null, 23 | "flexibleCollections": false, 24 | "hasPublicAndPrivateKeys": true, 25 | "id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 26 | "identifier": null, 27 | "key": "4.Oc8mQiv88uC4GuG9cPiCW7fpWiXAJ0Q1R1QvEuXjhpKsGA405FOTAvH9DpWZDrta3KG07ek273j7c7+z7g9VC0a+N7DS52DL29vIRz5sE8gDDxlK5vBVJz5tU8lrJiObBz93nYr0U3ujmcL4VTbchlrNAtz2Cp3LtlEQGKzT2isGZZm3GpCriZvls9IaapXRTXMDS0YlTo39zNSeR0xNe3kMAnM5fbiNe5RxFGdxwISOHczdPIF4e/k4n1+TTbmrQ1SieQIASgfCdCjRDhQdexMaoafKDgfjZBwwLn7d9kL2D/8ni9AhOxJzpsn3O3tgW2m+kWu+8ytGP9YE6jwMUw==", 28 | "keyConnectorEnabled": false, 29 | "keyConnectorUrl": null, 30 | "limitCollectionCreationDeletion": true, 31 | "maxCollections": 10, 32 | "maxStorageGb": 10, 33 | "name": "Test Organization", 34 | "object": "profileOrganization", 35 | "permissions": { 36 | "accessEventLogs": false, 37 | "accessImportExport": false, 38 | "accessReports": false, 39 | "createNewCollections": false, 40 | "deleteAnyCollection": false, 41 | "deleteAssignedCollections": false, 42 | "editAnyCollection": false, 43 | "editAssignedCollections": false, 44 | "manageGroups": false, 45 | "managePolicies": false, 46 | "manageResetPassword": false, 47 | "manageScim": false, 48 | "manageSso": false, 49 | "manageUsers": false 50 | }, 51 | "planProductType": 0, 52 | "providerId": null, 53 | "providerName": null, 54 | "providerType": null, 55 | "resetPasswordEnrolled": false, 56 | "seats": 10, 57 | "selfHost": true, 58 | "ssoBound": false, 59 | "status": 2, 60 | "type": 2, 61 | "use2fa": true, 62 | "useActivateAutofillPolicy": false, 63 | "useApi": true, 64 | "useCustomPermissions": false, 65 | "useDirectory": false, 66 | "useEvents": false, 67 | "useGroups": false, 68 | "useKeyConnector": false, 69 | "usePasswordManager": true, 70 | "usePolicies": true, 71 | "useResetPassword": false, 72 | "useScim": false, 73 | "useSecretsManager": false, 74 | "useSso": false, 75 | "useTotp": true, 76 | "userId": "cd95d118-e96d-4b8d-a000-a10c92dd8f88", 77 | "usersGetPremium": true 78 | } 79 | ], 80 | "premium": true, 81 | "premiumFromOrganization": false, 82 | "privateKey": "2.jwhyVLmpbVAdnDWAzWcC2A==|uK3ZVxUL1h23PuIMFwRF04TMLrwMph5eQaiof22jvvvSMr0lK96yoZgZ16Iwod62csJps0PLzPRTywfO8M3yZTzD/zVIY26NKc5fCdRotXFjNzt4AdGeBioLA5c3EzOlmD3Jc3Eefcu1tPR+j2HuuJLsaGlSrQ3SRn3JJTBrLavddApw/PS8yb4uz5NoE3U9gnMvD+Uf9SzGhiDlBMHWlFGQ1CZKtKNEY5HOginiOFHoswveMFtUZgxioYXzSqSWES9k1LSbrUZNBNqLHZhEbXAupYpD6peUe+KIFx0vNIiXzRt5vnuOEYku9eeCfPugRrVtH/FuTJEAvkz9Kbb0XR1u4YEMRi8k5b9bmwqE6EwYcIJ9Djg8XO6psP5M5Wz3ForPKRWYnRmkGS4MKjCX4JtnrNmEKGx5Gzw1YNiBwYkY6tA8lNMGKLqW9qufE2vGmkvF8cq3cG6QOd3nzUCcxmjAZuDo8ZWd7axv1y4J0TUqNQQQ2Bnd+ZMcORYUafV10fZ5AIKisdWhOw4HJXUcDWGXXmeftuA9kkUN1FZZI2bdYfDpBOzw9WBt4vGNbU2Uw/Px6u6DzwbEa+Pd4LTJem6oIyFhy/mNqZWjPyX46J0FHTPjqFGFwExvoBcCKPG6BDaZb3y22kxZr9Ss7LbV6Tax1JxA4I0elaX5CgrIozh/nji7f7oTdYljWYGA7Ts3Eb2mL1j+az1UHwi0qDVe1v8E4CBxZyNBw4JbuFQ1eTys6DOmkGPw00sngF0o1wFxgcRN9UK1DlmheF3omKwT42G8KAYPuPawDGZEtNOa9xoGVgVOXmKI4x+xFNenHm6oNd5WGrXDq7FCkkho32KmESmZhFxTaILJ4WrKOHUUDQhZ75K/jd67rQuvq0MbAD74+sxpQlosvuWtDWW9ceTRa0uEWrpHwB8vc9BbSqUwgdP03J38R/siNft06eBWtFktCQOQEZRv5VA+QSf5KPeH+0QNV2UtzpyiI7ce7mQlhXHvKXgf+p+QKN2U6nMH07KH1KlSQGTx58p/yEuReEDqht7/OCD9oQgUMtnY5gm3g+J4orz5tMtbV1RUSaeMUH+DN4gOgZlGFFw+gBVr5SLa1eIkdVpg86CdGUpODOJsnNGkFieQ+SEuUgZC1smPw270JVfDIwZ7jXplErw85zURY32tty8Lb1YaOkvIpyPx9ylMATpD1QkwlcUSoS6M9kiCeZGUWrTPDpmFI8fav79q3+X8xrZrQ3xCLKCii+d+Mban4M+liXLBGaZowqzWxv2d6EmxnJVzhJZqFMxcmOeCdwsgwbxUD6Ycd7fN/7rDBrIKOMiF3x/xlIpVLa3aA83dSQKsbkxVpjwS05fn53E96ZQaRX9avXRhIfsG3sD3TDvBU2disAi4wDszA3VgkLsxo9HZyiBdXVbzrdC97FqsIH49bmwBpj38pOhtkYu+JlXdXeKA9m1UIrKfgXY94dkEgO/qQnttZW6OmdfqFfJWx3qEv6/UoUxHoSdFlKDndkQIHfXQT3IlK8eHpUt0VdXs9JSkhcBsIZ6N/L2TN1kPhBMUr8W0eYu7yv9q/olSkCbF9NqyraFwvJP2IGr4WepOg4hn0lM2yVc1xzIXWqKNPaWj4AgTDzjqFQR8wPaHSC4=|anAl2GmUHBH7LaStnTMYYz3fPuqJ/obAyLb7waj5b8o=", 83 | "providerOrganizations": [], 84 | "providers": [], 85 | "securityStamp": "89c314b3-6645-4adb-a1c6-e470a977e6e4", 86 | "twoFactorEnabled": false, 87 | "usesKeyConnector": false 88 | } -------------------------------------------------------------------------------- /tests/fixtures/test-account-2/sync_camel.json: -------------------------------------------------------------------------------- 1 | { 2 | "ciphers": [ 3 | { 4 | "attachments": null, 5 | "card": null, 6 | "collectionIds": [], 7 | "creationDate": "2024-07-23T09:39:36.383086Z", 8 | "data": { 9 | "autofillOnPageLoad": null, 10 | "fields": [], 11 | "name": "2./3xFgTAgVkJs6idZtpcwuw==|1VwRVRXtjaT8krhE1mgCNg==|wm3vZZZusJaNZNw6QTSmb6prORAcUkcwA/kTKteQVvA=", 12 | "notes": null, 13 | "password": "2.oVErqSmQEmopz+xga1hpjg==|n7b4SvCtkUwvt0kt6Nhv9g==|uaaMkxnPHq3oCiedoAhN74D6pVflYMWhi4jmteRDOqo=", 14 | "passwordHistory": [], 15 | "passwordRevisionDate": null, 16 | "totp": null, 17 | "uri": null, 18 | "uris": [], 19 | "username": "2.xyfy7SXFQwcY/AUQmdANvQ==|Hu1DEuEHgrXU9bPAfn9KNg==|QkICrDZ1AP+hJDflNNEgH0bnFI020nysKAcZPgcpVMM=" 20 | }, 21 | "deletedDate": null, 22 | "edit": true, 23 | "favorite": false, 24 | "fields": [], 25 | "folderId": null, 26 | "id": "ec31abe3-3c7a-410e-9353-5a5d8e5782d8", 27 | "identity": null, 28 | "key": null, 29 | "login": { 30 | "autofillOnPageLoad": null, 31 | "password": "2.oVErqSmQEmopz+xga1hpjg==|n7b4SvCtkUwvt0kt6Nhv9g==|uaaMkxnPHq3oCiedoAhN74D6pVflYMWhi4jmteRDOqo=", 32 | "passwordRevisionDate": null, 33 | "totp": null, 34 | "uri": null, 35 | "uris": [], 36 | "username": "2.xyfy7SXFQwcY/AUQmdANvQ==|Hu1DEuEHgrXU9bPAfn9KNg==|QkICrDZ1AP+hJDflNNEgH0bnFI020nysKAcZPgcpVMM=" 37 | }, 38 | "name": "2./3xFgTAgVkJs6idZtpcwuw==|1VwRVRXtjaT8krhE1mgCNg==|wm3vZZZusJaNZNw6QTSmb6prORAcUkcwA/kTKteQVvA=", 39 | "notes": null, 40 | "object": "cipherDetails", 41 | "organizationId": null, 42 | "organizationUseTotp": true, 43 | "passwordHistory": [], 44 | "reprompt": 0, 45 | "revisionDate": "2024-07-23T09:39:36.383247Z", 46 | "secureNote": null, 47 | "type": 1, 48 | "viewPassword": true 49 | }, 50 | { 51 | "attachments": null, 52 | "card": null, 53 | "collectionIds": [ 54 | "3c73f14f-5a01-4016-98bb-9605146a1a49" 55 | ], 56 | "creationDate": "2024-07-23T09:40:50.678852Z", 57 | "data": { 58 | "autofillOnPageLoad": null, 59 | "fields": [], 60 | "name": "2.YFrZrHpUErMukhH02PpBJg==|euAdV2V6x6RhKRRDQ5DgRg==|MEu8r16SaQVtPTSpt3uPkYQ5saAmgGpRwLzZv64nDoI=", 61 | "notes": null, 62 | "password": "2.XaBC/gN/6A8rZBs82lnyZg==|XKpgx5euzvNrNcweWhOLtA==|4jsrMTGChg5Eh5U4nQiS5fpo9dKY5s7P39mWSSNl2a4=", 63 | "passwordHistory": [], 64 | "passwordRevisionDate": null, 65 | "totp": null, 66 | "uri": null, 67 | "uris": [], 68 | "username": "2.AwEPZzhBWbjdO3tmLsrI0A==|9WrHrtPiiGgtRXU23y7bmw==|BehLMa8tKqDU52jZDS4sktsbF3owXsL4ZWGjGchj/kY=" 69 | }, 70 | "deletedDate": null, 71 | "edit": false, 72 | "favorite": false, 73 | "fields": [], 74 | "folderId": null, 75 | "id": "fc246fe5-9177-455b-b318-c00fab407dc8", 76 | "identity": null, 77 | "key": null, 78 | "login": { 79 | "autofillOnPageLoad": null, 80 | "password": "2.XaBC/gN/6A8rZBs82lnyZg==|XKpgx5euzvNrNcweWhOLtA==|4jsrMTGChg5Eh5U4nQiS5fpo9dKY5s7P39mWSSNl2a4=", 81 | "passwordRevisionDate": null, 82 | "totp": null, 83 | "uri": null, 84 | "uris": [], 85 | "username": "2.AwEPZzhBWbjdO3tmLsrI0A==|9WrHrtPiiGgtRXU23y7bmw==|BehLMa8tKqDU52jZDS4sktsbF3owXsL4ZWGjGchj/kY=" 86 | }, 87 | "name": "2.YFrZrHpUErMukhH02PpBJg==|euAdV2V6x6RhKRRDQ5DgRg==|MEu8r16SaQVtPTSpt3uPkYQ5saAmgGpRwLzZv64nDoI=", 88 | "notes": null, 89 | "object": "cipherDetails", 90 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 91 | "organizationUseTotp": true, 92 | "passwordHistory": [], 93 | "reprompt": 0, 94 | "revisionDate": "2024-07-23T09:40:50.679370Z", 95 | "secureNote": null, 96 | "type": 1, 97 | "viewPassword": true 98 | } 99 | ], 100 | "collections": [ 101 | { 102 | "externalId": null, 103 | "hidePasswords": false, 104 | "id": "3c73f14f-5a01-4016-98bb-9605146a1a49", 105 | "name": "2.M5LLRUsBnTovXQuA4DBKLA==|ViL7ZxNENF6j28TjwwoHKN555BU9Wid75uvYyd0munE=|BIgdP+aizz0FrAJk5pTov4wbHME/Qm3GpJ0u1CgR/OE=", 106 | "object": "collectionDetails", 107 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 108 | "readOnly": true 109 | } 110 | ], 111 | "domains": { 112 | "equivalentDomains": [], 113 | "globalEquivalentDomains": [ 114 | { 115 | "domains": [ 116 | "ameritrade.com", 117 | "tdameritrade.com" 118 | ], 119 | "excluded": false, 120 | "type": 2 121 | }, 122 | { 123 | "domains": [ 124 | "bankofamerica.com", 125 | "bofa.com", 126 | "mbna.com", 127 | "usecfo.com" 128 | ], 129 | "excluded": false, 130 | "type": 3 131 | }, 132 | { 133 | "domains": [ 134 | "sprint.com", 135 | "sprintpcs.com", 136 | "nextel.com" 137 | ], 138 | "excluded": false, 139 | "type": 4 140 | }, 141 | { 142 | "domains": [ 143 | "youtube.com", 144 | "google.com", 145 | "gmail.com" 146 | ], 147 | "excluded": false, 148 | "type": 0 149 | }, 150 | { 151 | "domains": [ 152 | "apple.com", 153 | "icloud.com" 154 | ], 155 | "excluded": false, 156 | "type": 1 157 | }, 158 | { 159 | "domains": [ 160 | "wellsfargo.com", 161 | "wf.com", 162 | "wellsfargoadvisors.com" 163 | ], 164 | "excluded": false, 165 | "type": 5 166 | }, 167 | { 168 | "domains": [ 169 | "mymerrill.com", 170 | "ml.com", 171 | "merrilledge.com" 172 | ], 173 | "excluded": false, 174 | "type": 6 175 | }, 176 | { 177 | "domains": [ 178 | "accountonline.com", 179 | "citi.com", 180 | "citibank.com", 181 | "citicards.com", 182 | "citibankonline.com" 183 | ], 184 | "excluded": false, 185 | "type": 7 186 | }, 187 | { 188 | "domains": [ 189 | "cnet.com", 190 | "cnettv.com", 191 | "com.com", 192 | "download.com", 193 | "news.com", 194 | "search.com", 195 | "upload.com" 196 | ], 197 | "excluded": false, 198 | "type": 8 199 | }, 200 | { 201 | "domains": [ 202 | "bananarepublic.com", 203 | "gap.com", 204 | "oldnavy.com", 205 | "piperlime.com" 206 | ], 207 | "excluded": false, 208 | "type": 9 209 | }, 210 | { 211 | "domains": [ 212 | "bing.com", 213 | "hotmail.com", 214 | "live.com", 215 | "microsoft.com", 216 | "msn.com", 217 | "passport.net", 218 | "windows.com", 219 | "microsoftonline.com", 220 | "office.com", 221 | "office365.com", 222 | "microsoftstore.com", 223 | "xbox.com", 224 | "azure.com", 225 | "windowsazure.com" 226 | ], 227 | "excluded": false, 228 | "type": 10 229 | }, 230 | { 231 | "domains": [ 232 | "ua2go.com", 233 | "ual.com", 234 | "united.com", 235 | "unitedwifi.com" 236 | ], 237 | "excluded": false, 238 | "type": 11 239 | }, 240 | { 241 | "domains": [ 242 | "overture.com", 243 | "yahoo.com" 244 | ], 245 | "excluded": false, 246 | "type": 12 247 | }, 248 | { 249 | "domains": [ 250 | "zonealarm.com", 251 | "zonelabs.com" 252 | ], 253 | "excluded": false, 254 | "type": 13 255 | }, 256 | { 257 | "domains": [ 258 | "paypal.com", 259 | "paypal-search.com" 260 | ], 261 | "excluded": false, 262 | "type": 14 263 | }, 264 | { 265 | "domains": [ 266 | "avon.com", 267 | "youravon.com" 268 | ], 269 | "excluded": false, 270 | "type": 15 271 | }, 272 | { 273 | "domains": [ 274 | "diapers.com", 275 | "soap.com", 276 | "wag.com", 277 | "yoyo.com", 278 | "beautybar.com", 279 | "casa.com", 280 | "afterschool.com", 281 | "vine.com", 282 | "bookworm.com", 283 | "look.com", 284 | "vinemarket.com" 285 | ], 286 | "excluded": false, 287 | "type": 16 288 | }, 289 | { 290 | "domains": [ 291 | "1800contacts.com", 292 | "800contacts.com" 293 | ], 294 | "excluded": false, 295 | "type": 17 296 | }, 297 | { 298 | "domains": [ 299 | "amazon.com", 300 | "amazon.com.be", 301 | "amazon.ae", 302 | "amazon.ca", 303 | "amazon.co.uk", 304 | "amazon.com.au", 305 | "amazon.com.br", 306 | "amazon.com.mx", 307 | "amazon.com.tr", 308 | "amazon.de", 309 | "amazon.es", 310 | "amazon.fr", 311 | "amazon.in", 312 | "amazon.it", 313 | "amazon.nl", 314 | "amazon.pl", 315 | "amazon.sa", 316 | "amazon.se", 317 | "amazon.sg" 318 | ], 319 | "excluded": false, 320 | "type": 18 321 | }, 322 | { 323 | "domains": [ 324 | "cox.com", 325 | "cox.net", 326 | "coxbusiness.com" 327 | ], 328 | "excluded": false, 329 | "type": 19 330 | }, 331 | { 332 | "domains": [ 333 | "mynortonaccount.com", 334 | "norton.com" 335 | ], 336 | "excluded": false, 337 | "type": 20 338 | }, 339 | { 340 | "domains": [ 341 | "verizon.com", 342 | "verizon.net" 343 | ], 344 | "excluded": false, 345 | "type": 21 346 | }, 347 | { 348 | "domains": [ 349 | "rakuten.com", 350 | "buy.com" 351 | ], 352 | "excluded": false, 353 | "type": 22 354 | }, 355 | { 356 | "domains": [ 357 | "siriusxm.com", 358 | "sirius.com" 359 | ], 360 | "excluded": false, 361 | "type": 23 362 | }, 363 | { 364 | "domains": [ 365 | "ea.com", 366 | "origin.com", 367 | "play4free.com", 368 | "tiberiumalliance.com" 369 | ], 370 | "excluded": false, 371 | "type": 24 372 | }, 373 | { 374 | "domains": [ 375 | "37signals.com", 376 | "basecamp.com", 377 | "basecamphq.com", 378 | "highrisehq.com" 379 | ], 380 | "excluded": false, 381 | "type": 25 382 | }, 383 | { 384 | "domains": [ 385 | "steampowered.com", 386 | "steamcommunity.com", 387 | "steamgames.com" 388 | ], 389 | "excluded": false, 390 | "type": 26 391 | }, 392 | { 393 | "domains": [ 394 | "chart.io", 395 | "chartio.com" 396 | ], 397 | "excluded": false, 398 | "type": 27 399 | }, 400 | { 401 | "domains": [ 402 | "gotomeeting.com", 403 | "citrixonline.com" 404 | ], 405 | "excluded": false, 406 | "type": 28 407 | }, 408 | { 409 | "domains": [ 410 | "gogoair.com", 411 | "gogoinflight.com" 412 | ], 413 | "excluded": false, 414 | "type": 29 415 | }, 416 | { 417 | "domains": [ 418 | "mysql.com", 419 | "oracle.com" 420 | ], 421 | "excluded": false, 422 | "type": 30 423 | }, 424 | { 425 | "domains": [ 426 | "discover.com", 427 | "discovercard.com" 428 | ], 429 | "excluded": false, 430 | "type": 31 431 | }, 432 | { 433 | "domains": [ 434 | "dcu.org", 435 | "dcu-online.org" 436 | ], 437 | "excluded": false, 438 | "type": 32 439 | }, 440 | { 441 | "domains": [ 442 | "healthcare.gov", 443 | "cuidadodesalud.gov", 444 | "cms.gov" 445 | ], 446 | "excluded": false, 447 | "type": 33 448 | }, 449 | { 450 | "domains": [ 451 | "pepco.com", 452 | "pepcoholdings.com" 453 | ], 454 | "excluded": false, 455 | "type": 34 456 | }, 457 | { 458 | "domains": [ 459 | "century21.com", 460 | "21online.com" 461 | ], 462 | "excluded": false, 463 | "type": 35 464 | }, 465 | { 466 | "domains": [ 467 | "comcast.com", 468 | "comcast.net", 469 | "xfinity.com" 470 | ], 471 | "excluded": false, 472 | "type": 36 473 | }, 474 | { 475 | "domains": [ 476 | "cricketwireless.com", 477 | "aiowireless.com" 478 | ], 479 | "excluded": false, 480 | "type": 37 481 | }, 482 | { 483 | "domains": [ 484 | "mandtbank.com", 485 | "mtb.com" 486 | ], 487 | "excluded": false, 488 | "type": 38 489 | }, 490 | { 491 | "domains": [ 492 | "dropbox.com", 493 | "getdropbox.com" 494 | ], 495 | "excluded": false, 496 | "type": 39 497 | }, 498 | { 499 | "domains": [ 500 | "snapfish.com", 501 | "snapfish.ca" 502 | ], 503 | "excluded": false, 504 | "type": 40 505 | }, 506 | { 507 | "domains": [ 508 | "alibaba.com", 509 | "aliexpress.com", 510 | "aliyun.com", 511 | "net.cn" 512 | ], 513 | "excluded": false, 514 | "type": 41 515 | }, 516 | { 517 | "domains": [ 518 | "playstation.com", 519 | "sonyentertainmentnetwork.com" 520 | ], 521 | "excluded": false, 522 | "type": 42 523 | }, 524 | { 525 | "domains": [ 526 | "mercadolivre.com", 527 | "mercadolivre.com.br", 528 | "mercadolibre.com", 529 | "mercadolibre.com.ar", 530 | "mercadolibre.com.mx" 531 | ], 532 | "excluded": false, 533 | "type": 43 534 | }, 535 | { 536 | "domains": [ 537 | "zendesk.com", 538 | "zopim.com" 539 | ], 540 | "excluded": false, 541 | "type": 44 542 | }, 543 | { 544 | "domains": [ 545 | "autodesk.com", 546 | "tinkercad.com" 547 | ], 548 | "excluded": false, 549 | "type": 45 550 | }, 551 | { 552 | "domains": [ 553 | "railnation.ru", 554 | "railnation.de", 555 | "rail-nation.com", 556 | "railnation.gr", 557 | "railnation.us", 558 | "trucknation.de", 559 | "traviangames.com" 560 | ], 561 | "excluded": false, 562 | "type": 46 563 | }, 564 | { 565 | "domains": [ 566 | "wpcu.coop", 567 | "wpcuonline.com" 568 | ], 569 | "excluded": false, 570 | "type": 47 571 | }, 572 | { 573 | "domains": [ 574 | "mathletics.com", 575 | "mathletics.com.au", 576 | "mathletics.co.uk" 577 | ], 578 | "excluded": false, 579 | "type": 48 580 | }, 581 | { 582 | "domains": [ 583 | "discountbank.co.il", 584 | "telebank.co.il" 585 | ], 586 | "excluded": false, 587 | "type": 49 588 | }, 589 | { 590 | "domains": [ 591 | "mi.com", 592 | "xiaomi.com" 593 | ], 594 | "excluded": false, 595 | "type": 50 596 | }, 597 | { 598 | "domains": [ 599 | "postepay.it", 600 | "poste.it" 601 | ], 602 | "excluded": false, 603 | "type": 52 604 | }, 605 | { 606 | "domains": [ 607 | "facebook.com", 608 | "messenger.com" 609 | ], 610 | "excluded": false, 611 | "type": 51 612 | }, 613 | { 614 | "domains": [ 615 | "skysports.com", 616 | "skybet.com", 617 | "skyvegas.com" 618 | ], 619 | "excluded": false, 620 | "type": 53 621 | }, 622 | { 623 | "domains": [ 624 | "disneymoviesanywhere.com", 625 | "go.com", 626 | "disney.com", 627 | "dadt.com", 628 | "disneyplus.com" 629 | ], 630 | "excluded": false, 631 | "type": 54 632 | }, 633 | { 634 | "domains": [ 635 | "pokemon-gl.com", 636 | "pokemon.com" 637 | ], 638 | "excluded": false, 639 | "type": 55 640 | }, 641 | { 642 | "domains": [ 643 | "myuv.com", 644 | "uvvu.com" 645 | ], 646 | "excluded": false, 647 | "type": 56 648 | }, 649 | { 650 | "domains": [ 651 | "mdsol.com", 652 | "imedidata.com" 653 | ], 654 | "excluded": false, 655 | "type": 58 656 | }, 657 | { 658 | "domains": [ 659 | "bank-yahav.co.il", 660 | "bankhapoalim.co.il" 661 | ], 662 | "excluded": false, 663 | "type": 57 664 | }, 665 | { 666 | "domains": [ 667 | "sears.com", 668 | "shld.net" 669 | ], 670 | "excluded": false, 671 | "type": 59 672 | }, 673 | { 674 | "domains": [ 675 | "xiami.com", 676 | "alipay.com" 677 | ], 678 | "excluded": false, 679 | "type": 60 680 | }, 681 | { 682 | "domains": [ 683 | "belkin.com", 684 | "seedonk.com" 685 | ], 686 | "excluded": false, 687 | "type": 61 688 | }, 689 | { 690 | "domains": [ 691 | "turbotax.com", 692 | "intuit.com" 693 | ], 694 | "excluded": false, 695 | "type": 62 696 | }, 697 | { 698 | "domains": [ 699 | "shopify.com", 700 | "myshopify.com" 701 | ], 702 | "excluded": false, 703 | "type": 63 704 | }, 705 | { 706 | "domains": [ 707 | "ebay.com", 708 | "ebay.at", 709 | "ebay.be", 710 | "ebay.ca", 711 | "ebay.ch", 712 | "ebay.cn", 713 | "ebay.co.jp", 714 | "ebay.co.th", 715 | "ebay.co.uk", 716 | "ebay.com.au", 717 | "ebay.com.hk", 718 | "ebay.com.my", 719 | "ebay.com.sg", 720 | "ebay.com.tw", 721 | "ebay.de", 722 | "ebay.es", 723 | "ebay.fr", 724 | "ebay.ie", 725 | "ebay.in", 726 | "ebay.it", 727 | "ebay.nl", 728 | "ebay.ph", 729 | "ebay.pl" 730 | ], 731 | "excluded": false, 732 | "type": 64 733 | }, 734 | { 735 | "domains": [ 736 | "techdata.com", 737 | "techdata.ch" 738 | ], 739 | "excluded": false, 740 | "type": 65 741 | }, 742 | { 743 | "domains": [ 744 | "schwab.com", 745 | "schwabplan.com" 746 | ], 747 | "excluded": false, 748 | "type": 66 749 | }, 750 | { 751 | "domains": [ 752 | "tesla.com", 753 | "teslamotors.com" 754 | ], 755 | "excluded": false, 756 | "type": 68 757 | }, 758 | { 759 | "domains": [ 760 | "morganstanley.com", 761 | "morganstanleyclientserv.com", 762 | "stockplanconnect.com", 763 | "ms.com" 764 | ], 765 | "excluded": false, 766 | "type": 69 767 | }, 768 | { 769 | "domains": [ 770 | "taxact.com", 771 | "taxactonline.com" 772 | ], 773 | "excluded": false, 774 | "type": 70 775 | }, 776 | { 777 | "domains": [ 778 | "mediawiki.org", 779 | "wikibooks.org", 780 | "wikidata.org", 781 | "wikimedia.org", 782 | "wikinews.org", 783 | "wikipedia.org", 784 | "wikiquote.org", 785 | "wikisource.org", 786 | "wikiversity.org", 787 | "wikivoyage.org", 788 | "wiktionary.org" 789 | ], 790 | "excluded": false, 791 | "type": 71 792 | }, 793 | { 794 | "domains": [ 795 | "airbnb.at", 796 | "airbnb.be", 797 | "airbnb.ca", 798 | "airbnb.ch", 799 | "airbnb.cl", 800 | "airbnb.co.cr", 801 | "airbnb.co.id", 802 | "airbnb.co.in", 803 | "airbnb.co.kr", 804 | "airbnb.co.nz", 805 | "airbnb.co.uk", 806 | "airbnb.co.ve", 807 | "airbnb.com", 808 | "airbnb.com.ar", 809 | "airbnb.com.au", 810 | "airbnb.com.bo", 811 | "airbnb.com.br", 812 | "airbnb.com.bz", 813 | "airbnb.com.co", 814 | "airbnb.com.ec", 815 | "airbnb.com.gt", 816 | "airbnb.com.hk", 817 | "airbnb.com.hn", 818 | "airbnb.com.mt", 819 | "airbnb.com.my", 820 | "airbnb.com.ni", 821 | "airbnb.com.pa", 822 | "airbnb.com.pe", 823 | "airbnb.com.py", 824 | "airbnb.com.sg", 825 | "airbnb.com.sv", 826 | "airbnb.com.tr", 827 | "airbnb.com.tw", 828 | "airbnb.cz", 829 | "airbnb.de", 830 | "airbnb.dk", 831 | "airbnb.es", 832 | "airbnb.fi", 833 | "airbnb.fr", 834 | "airbnb.gr", 835 | "airbnb.gy", 836 | "airbnb.hu", 837 | "airbnb.ie", 838 | "airbnb.is", 839 | "airbnb.it", 840 | "airbnb.jp", 841 | "airbnb.mx", 842 | "airbnb.nl", 843 | "airbnb.no", 844 | "airbnb.pl", 845 | "airbnb.pt", 846 | "airbnb.ru", 847 | "airbnb.se" 848 | ], 849 | "excluded": false, 850 | "type": 72 851 | }, 852 | { 853 | "domains": [ 854 | "eventbrite.at", 855 | "eventbrite.be", 856 | "eventbrite.ca", 857 | "eventbrite.ch", 858 | "eventbrite.cl", 859 | "eventbrite.co", 860 | "eventbrite.co.nz", 861 | "eventbrite.co.uk", 862 | "eventbrite.com", 863 | "eventbrite.com.ar", 864 | "eventbrite.com.au", 865 | "eventbrite.com.br", 866 | "eventbrite.com.mx", 867 | "eventbrite.com.pe", 868 | "eventbrite.de", 869 | "eventbrite.dk", 870 | "eventbrite.es", 871 | "eventbrite.fi", 872 | "eventbrite.fr", 873 | "eventbrite.hk", 874 | "eventbrite.ie", 875 | "eventbrite.it", 876 | "eventbrite.nl", 877 | "eventbrite.pt", 878 | "eventbrite.se", 879 | "eventbrite.sg" 880 | ], 881 | "excluded": false, 882 | "type": 73 883 | }, 884 | { 885 | "domains": [ 886 | "stackexchange.com", 887 | "superuser.com", 888 | "stackoverflow.com", 889 | "serverfault.com", 890 | "mathoverflow.net", 891 | "askubuntu.com", 892 | "stackapps.com" 893 | ], 894 | "excluded": false, 895 | "type": 74 896 | }, 897 | { 898 | "domains": [ 899 | "docusign.com", 900 | "docusign.net" 901 | ], 902 | "excluded": false, 903 | "type": 75 904 | }, 905 | { 906 | "domains": [ 907 | "envato.com", 908 | "themeforest.net", 909 | "codecanyon.net", 910 | "videohive.net", 911 | "audiojungle.net", 912 | "graphicriver.net", 913 | "photodune.net", 914 | "3docean.net" 915 | ], 916 | "excluded": false, 917 | "type": 76 918 | }, 919 | { 920 | "domains": [ 921 | "x10hosting.com", 922 | "x10premium.com" 923 | ], 924 | "excluded": false, 925 | "type": 77 926 | }, 927 | { 928 | "domains": [ 929 | "dnsomatic.com", 930 | "opendns.com", 931 | "umbrella.com" 932 | ], 933 | "excluded": false, 934 | "type": 78 935 | }, 936 | { 937 | "domains": [ 938 | "cagreatamerica.com", 939 | "canadaswonderland.com", 940 | "carowinds.com", 941 | "cedarfair.com", 942 | "cedarpoint.com", 943 | "dorneypark.com", 944 | "kingsdominion.com", 945 | "knotts.com", 946 | "miadventure.com", 947 | "schlitterbahn.com", 948 | "valleyfair.com", 949 | "visitkingsisland.com", 950 | "worldsoffun.com" 951 | ], 952 | "excluded": false, 953 | "type": 79 954 | }, 955 | { 956 | "domains": [ 957 | "ubnt.com", 958 | "ui.com" 959 | ], 960 | "excluded": false, 961 | "type": 80 962 | }, 963 | { 964 | "domains": [ 965 | "discordapp.com", 966 | "discord.com" 967 | ], 968 | "excluded": false, 969 | "type": 81 970 | }, 971 | { 972 | "domains": [ 973 | "netcup.de", 974 | "netcup.eu", 975 | "customercontrolpanel.de" 976 | ], 977 | "excluded": false, 978 | "type": 82 979 | }, 980 | { 981 | "domains": [ 982 | "yandex.com", 983 | "ya.ru", 984 | "yandex.az", 985 | "yandex.by", 986 | "yandex.co.il", 987 | "yandex.com.am", 988 | "yandex.com.ge", 989 | "yandex.com.tr", 990 | "yandex.ee", 991 | "yandex.fi", 992 | "yandex.fr", 993 | "yandex.kg", 994 | "yandex.kz", 995 | "yandex.lt", 996 | "yandex.lv", 997 | "yandex.md", 998 | "yandex.pl", 999 | "yandex.ru", 1000 | "yandex.tj", 1001 | "yandex.tm", 1002 | "yandex.ua", 1003 | "yandex.uz" 1004 | ], 1005 | "excluded": false, 1006 | "type": 83 1007 | }, 1008 | { 1009 | "domains": [ 1010 | "sonyentertainmentnetwork.com", 1011 | "sony.com" 1012 | ], 1013 | "excluded": false, 1014 | "type": 84 1015 | }, 1016 | { 1017 | "domains": [ 1018 | "proton.me", 1019 | "protonmail.com", 1020 | "protonvpn.com" 1021 | ], 1022 | "excluded": false, 1023 | "type": 85 1024 | }, 1025 | { 1026 | "domains": [ 1027 | "ubisoft.com", 1028 | "ubi.com" 1029 | ], 1030 | "excluded": false, 1031 | "type": 86 1032 | }, 1033 | { 1034 | "domains": [ 1035 | "transferwise.com", 1036 | "wise.com" 1037 | ], 1038 | "excluded": false, 1039 | "type": 87 1040 | }, 1041 | { 1042 | "domains": [ 1043 | "takeaway.com", 1044 | "just-eat.dk", 1045 | "just-eat.no", 1046 | "just-eat.fr", 1047 | "just-eat.ch", 1048 | "lieferando.de", 1049 | "lieferando.at", 1050 | "thuisbezorgd.nl", 1051 | "pyszne.pl" 1052 | ], 1053 | "excluded": false, 1054 | "type": 88 1055 | }, 1056 | { 1057 | "domains": [ 1058 | "atlassian.com", 1059 | "bitbucket.org", 1060 | "trello.com", 1061 | "statuspage.io", 1062 | "atlassian.net", 1063 | "jira.com" 1064 | ], 1065 | "excluded": false, 1066 | "type": 89 1067 | }, 1068 | { 1069 | "domains": [ 1070 | "pinterest.com", 1071 | "pinterest.com.au", 1072 | "pinterest.cl", 1073 | "pinterest.de", 1074 | "pinterest.dk", 1075 | "pinterest.es", 1076 | "pinterest.fr", 1077 | "pinterest.co.uk", 1078 | "pinterest.jp", 1079 | "pinterest.co.kr", 1080 | "pinterest.nz", 1081 | "pinterest.pt", 1082 | "pinterest.se" 1083 | ], 1084 | "excluded": false, 1085 | "type": 90 1086 | } 1087 | ], 1088 | "object": "domains" 1089 | }, 1090 | "folders": [], 1091 | "object": "sync", 1092 | "policies": [], 1093 | "profile": { 1094 | "_status": 0, 1095 | "avatarColor": null, 1096 | "culture": "en-US", 1097 | "email": "test-account-2@example.com", 1098 | "emailVerified": true, 1099 | "forcePasswordReset": false, 1100 | "id": "cd95d118-e96d-4b8d-a000-a10c92dd8f88", 1101 | "key": "2.Y2xq0VALTE95WfqukeGjRA==|ycjbWhJ+LCSRmQyjil6CY6ylkHUtb4rIjIUjiaDSNZTIhwUpDBewINyou2HsBmr/JRj4bljVLcwYK/LzeCcstizhUf9KzveYkPiTfvBNzmk=|3CLBCSMdLRElzR0h+wm8JvxiYkkoHS9WO3MHpRMMAc4=", 1102 | "masterPasswordHint": null, 1103 | "name": "Test Account 2", 1104 | "object": "profile", 1105 | "organizations": [ 1106 | { 1107 | "accessSecretsManager": false, 1108 | "allowAdminAccessToAllCollectionItems": true, 1109 | "enabled": true, 1110 | "familySponsorshipAvailable": false, 1111 | "familySponsorshipFriendlyName": null, 1112 | "familySponsorshipLastSyncDate": null, 1113 | "familySponsorshipToDelete": null, 1114 | "familySponsorshipValidUntil": null, 1115 | "flexibleCollections": false, 1116 | "hasPublicAndPrivateKeys": true, 1117 | "id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 1118 | "identifier": null, 1119 | "key": "4.Oc8mQiv88uC4GuG9cPiCW7fpWiXAJ0Q1R1QvEuXjhpKsGA405FOTAvH9DpWZDrta3KG07ek273j7c7+z7g9VC0a+N7DS52DL29vIRz5sE8gDDxlK5vBVJz5tU8lrJiObBz93nYr0U3ujmcL4VTbchlrNAtz2Cp3LtlEQGKzT2isGZZm3GpCriZvls9IaapXRTXMDS0YlTo39zNSeR0xNe3kMAnM5fbiNe5RxFGdxwISOHczdPIF4e/k4n1+TTbmrQ1SieQIASgfCdCjRDhQdexMaoafKDgfjZBwwLn7d9kL2D/8ni9AhOxJzpsn3O3tgW2m+kWu+8ytGP9YE6jwMUw==", 1120 | "keyConnectorEnabled": false, 1121 | "keyConnectorUrl": null, 1122 | "limitCollectionCreationDeletion": true, 1123 | "maxCollections": 10, 1124 | "maxStorageGb": 10, 1125 | "name": "Test Organization", 1126 | "object": "profileOrganization", 1127 | "permissions": { 1128 | "accessEventLogs": false, 1129 | "accessImportExport": false, 1130 | "accessReports": false, 1131 | "createNewCollections": false, 1132 | "deleteAnyCollection": false, 1133 | "deleteAssignedCollections": false, 1134 | "editAnyCollection": false, 1135 | "editAssignedCollections": false, 1136 | "manageGroups": false, 1137 | "managePolicies": false, 1138 | "manageResetPassword": false, 1139 | "manageScim": false, 1140 | "manageSso": false, 1141 | "manageUsers": false 1142 | }, 1143 | "planProductType": 0, 1144 | "providerId": null, 1145 | "providerName": null, 1146 | "providerType": null, 1147 | "resetPasswordEnrolled": false, 1148 | "seats": 10, 1149 | "selfHost": true, 1150 | "ssoBound": false, 1151 | "status": 2, 1152 | "type": 2, 1153 | "use2fa": true, 1154 | "useActivateAutofillPolicy": false, 1155 | "useApi": true, 1156 | "useCustomPermissions": false, 1157 | "useDirectory": false, 1158 | "useEvents": false, 1159 | "useGroups": false, 1160 | "useKeyConnector": false, 1161 | "usePasswordManager": true, 1162 | "usePolicies": true, 1163 | "useResetPassword": false, 1164 | "useScim": false, 1165 | "useSecretsManager": false, 1166 | "useSso": false, 1167 | "useTotp": true, 1168 | "userId": "cd95d118-e96d-4b8d-a000-a10c92dd8f88", 1169 | "usersGetPremium": true 1170 | } 1171 | ], 1172 | "premium": true, 1173 | "premiumFromOrganization": false, 1174 | "privateKey": "2.jwhyVLmpbVAdnDWAzWcC2A==|uK3ZVxUL1h23PuIMFwRF04TMLrwMph5eQaiof22jvvvSMr0lK96yoZgZ16Iwod62csJps0PLzPRTywfO8M3yZTzD/zVIY26NKc5fCdRotXFjNzt4AdGeBioLA5c3EzOlmD3Jc3Eefcu1tPR+j2HuuJLsaGlSrQ3SRn3JJTBrLavddApw/PS8yb4uz5NoE3U9gnMvD+Uf9SzGhiDlBMHWlFGQ1CZKtKNEY5HOginiOFHoswveMFtUZgxioYXzSqSWES9k1LSbrUZNBNqLHZhEbXAupYpD6peUe+KIFx0vNIiXzRt5vnuOEYku9eeCfPugRrVtH/FuTJEAvkz9Kbb0XR1u4YEMRi8k5b9bmwqE6EwYcIJ9Djg8XO6psP5M5Wz3ForPKRWYnRmkGS4MKjCX4JtnrNmEKGx5Gzw1YNiBwYkY6tA8lNMGKLqW9qufE2vGmkvF8cq3cG6QOd3nzUCcxmjAZuDo8ZWd7axv1y4J0TUqNQQQ2Bnd+ZMcORYUafV10fZ5AIKisdWhOw4HJXUcDWGXXmeftuA9kkUN1FZZI2bdYfDpBOzw9WBt4vGNbU2Uw/Px6u6DzwbEa+Pd4LTJem6oIyFhy/mNqZWjPyX46J0FHTPjqFGFwExvoBcCKPG6BDaZb3y22kxZr9Ss7LbV6Tax1JxA4I0elaX5CgrIozh/nji7f7oTdYljWYGA7Ts3Eb2mL1j+az1UHwi0qDVe1v8E4CBxZyNBw4JbuFQ1eTys6DOmkGPw00sngF0o1wFxgcRN9UK1DlmheF3omKwT42G8KAYPuPawDGZEtNOa9xoGVgVOXmKI4x+xFNenHm6oNd5WGrXDq7FCkkho32KmESmZhFxTaILJ4WrKOHUUDQhZ75K/jd67rQuvq0MbAD74+sxpQlosvuWtDWW9ceTRa0uEWrpHwB8vc9BbSqUwgdP03J38R/siNft06eBWtFktCQOQEZRv5VA+QSf5KPeH+0QNV2UtzpyiI7ce7mQlhXHvKXgf+p+QKN2U6nMH07KH1KlSQGTx58p/yEuReEDqht7/OCD9oQgUMtnY5gm3g+J4orz5tMtbV1RUSaeMUH+DN4gOgZlGFFw+gBVr5SLa1eIkdVpg86CdGUpODOJsnNGkFieQ+SEuUgZC1smPw270JVfDIwZ7jXplErw85zURY32tty8Lb1YaOkvIpyPx9ylMATpD1QkwlcUSoS6M9kiCeZGUWrTPDpmFI8fav79q3+X8xrZrQ3xCLKCii+d+Mban4M+liXLBGaZowqzWxv2d6EmxnJVzhJZqFMxcmOeCdwsgwbxUD6Ycd7fN/7rDBrIKOMiF3x/xlIpVLa3aA83dSQKsbkxVpjwS05fn53E96ZQaRX9avXRhIfsG3sD3TDvBU2disAi4wDszA3VgkLsxo9HZyiBdXVbzrdC97FqsIH49bmwBpj38pOhtkYu+JlXdXeKA9m1UIrKfgXY94dkEgO/qQnttZW6OmdfqFfJWx3qEv6/UoUxHoSdFlKDndkQIHfXQT3IlK8eHpUt0VdXs9JSkhcBsIZ6N/L2TN1kPhBMUr8W0eYu7yv9q/olSkCbF9NqyraFwvJP2IGr4WepOg4hn0lM2yVc1xzIXWqKNPaWj4AgTDzjqFQR8wPaHSC4=|anAl2GmUHBH7LaStnTMYYz3fPuqJ/obAyLb7waj5b8o=", 1175 | "providerOrganizations": [], 1176 | "providers": [], 1177 | "securityStamp": "89c314b3-6645-4adb-a1c6-e470a977e6e4", 1178 | "twoFactorEnabled": false, 1179 | "usesKeyConnector": false 1180 | }, 1181 | "sends": [], 1182 | "unofficialServer": true 1183 | } -------------------------------------------------------------------------------- /tests/fixtures/test-account/sync_camel.json: -------------------------------------------------------------------------------- 1 | { 2 | "ciphers": [ 3 | { 4 | "attachments": null, 5 | "card": null, 6 | "collectionIds": [], 7 | "creationDate": "2024-07-23T09:45:02.427052Z", 8 | "data": { 9 | "autofillOnPageLoad": null, 10 | "fields": [], 11 | "name": "2.7+F6j8lp/fLGquyYCucJmQ==|EAvNo1z+agjIiQbpwb38yQ==|G8FVWnxcZjMqPcKVStnWpUWkkgs2kY8m8IcYgRJ7CR8=", 12 | "notes": null, 13 | "password": "2.hRIeQDJ3R3T8ioQ9fZe/QA==|0oEy7d+s/7rbd3yRh603OA==|9wR6eB42YTsHGzS4Bxqpq0II8uAJWmh2cUrk3TJMOUQ=", 14 | "passwordHistory": [], 15 | "passwordRevisionDate": null, 16 | "totp": null, 17 | "uri": null, 18 | "uris": [], 19 | "username": "2.AwjnfebCr1/I+wC28tn0nw==|HOfQmbfcvs+NjBZAs5gC7Q==|PlGBYM4Mrkfi3drSv0txw0tFLEsd0JYl3ZLotkXuTuM=" 20 | }, 21 | "deletedDate": null, 22 | "edit": true, 23 | "favorite": false, 24 | "fields": [], 25 | "folderId": null, 26 | "id": "921b94a6-d270-4889-88c2-c2531054c02e", 27 | "identity": null, 28 | "key": null, 29 | "login": { 30 | "autofillOnPageLoad": null, 31 | "password": "2.hRIeQDJ3R3T8ioQ9fZe/QA==|0oEy7d+s/7rbd3yRh603OA==|9wR6eB42YTsHGzS4Bxqpq0II8uAJWmh2cUrk3TJMOUQ=", 32 | "passwordRevisionDate": null, 33 | "totp": null, 34 | "uri": null, 35 | "uris": [], 36 | "username": "2.AwjnfebCr1/I+wC28tn0nw==|HOfQmbfcvs+NjBZAs5gC7Q==|PlGBYM4Mrkfi3drSv0txw0tFLEsd0JYl3ZLotkXuTuM=" 37 | }, 38 | "name": "2.7+F6j8lp/fLGquyYCucJmQ==|EAvNo1z+agjIiQbpwb38yQ==|G8FVWnxcZjMqPcKVStnWpUWkkgs2kY8m8IcYgRJ7CR8=", 39 | "notes": null, 40 | "object": "cipherDetails", 41 | "organizationId": null, 42 | "organizationUseTotp": true, 43 | "passwordHistory": [], 44 | "reprompt": 0, 45 | "revisionDate": "2024-07-23T09:45:02.427261Z", 46 | "secureNote": null, 47 | "type": 1, 48 | "viewPassword": true 49 | }, 50 | { 51 | "attachments": null, 52 | "card": null, 53 | "collectionIds": [ 54 | "3c73f14f-5a01-4016-98bb-9605146a1a49" 55 | ], 56 | "creationDate": "2024-07-23T09:40:50.678852Z", 57 | "data": { 58 | "autofillOnPageLoad": null, 59 | "fields": [], 60 | "name": "2.YFrZrHpUErMukhH02PpBJg==|euAdV2V6x6RhKRRDQ5DgRg==|MEu8r16SaQVtPTSpt3uPkYQ5saAmgGpRwLzZv64nDoI=", 61 | "notes": null, 62 | "password": "2.XaBC/gN/6A8rZBs82lnyZg==|XKpgx5euzvNrNcweWhOLtA==|4jsrMTGChg5Eh5U4nQiS5fpo9dKY5s7P39mWSSNl2a4=", 63 | "passwordHistory": [], 64 | "passwordRevisionDate": null, 65 | "totp": null, 66 | "uri": null, 67 | "uris": [], 68 | "username": "2.AwEPZzhBWbjdO3tmLsrI0A==|9WrHrtPiiGgtRXU23y7bmw==|BehLMa8tKqDU52jZDS4sktsbF3owXsL4ZWGjGchj/kY=" 69 | }, 70 | "deletedDate": null, 71 | "edit": true, 72 | "favorite": false, 73 | "fields": [], 74 | "folderId": null, 75 | "id": "fc246fe5-9177-455b-b318-c00fab407dc8", 76 | "identity": null, 77 | "key": null, 78 | "login": { 79 | "autofillOnPageLoad": null, 80 | "password": "2.XaBC/gN/6A8rZBs82lnyZg==|XKpgx5euzvNrNcweWhOLtA==|4jsrMTGChg5Eh5U4nQiS5fpo9dKY5s7P39mWSSNl2a4=", 81 | "passwordRevisionDate": null, 82 | "totp": null, 83 | "uri": null, 84 | "uris": [], 85 | "username": "2.AwEPZzhBWbjdO3tmLsrI0A==|9WrHrtPiiGgtRXU23y7bmw==|BehLMa8tKqDU52jZDS4sktsbF3owXsL4ZWGjGchj/kY=" 86 | }, 87 | "name": "2.YFrZrHpUErMukhH02PpBJg==|euAdV2V6x6RhKRRDQ5DgRg==|MEu8r16SaQVtPTSpt3uPkYQ5saAmgGpRwLzZv64nDoI=", 88 | "notes": null, 89 | "object": "cipherDetails", 90 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 91 | "organizationUseTotp": true, 92 | "passwordHistory": [], 93 | "reprompt": 0, 94 | "revisionDate": "2024-07-23T09:40:50.679370Z", 95 | "secureNote": null, 96 | "type": 1, 97 | "viewPassword": true 98 | } 99 | ], 100 | "collections": [ 101 | { 102 | "externalId": null, 103 | "hidePasswords": false, 104 | "id": "10370e0f-c916-4ead-9767-c4d75d0ef1f3", 105 | "name": "2.UFQ61Bp4hihu31h+WqjjCw==|poUtkoWSw+INpaxsnMp6g5ETt+v0lWNV9rXvxRLx6b8=|AEQzWIqJYoNQ0+ntzdqA76/wsxe4C0SVRS8yz/pio+w=", 106 | "object": "collectionDetails", 107 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 108 | "readOnly": false 109 | }, 110 | { 111 | "externalId": null, 112 | "hidePasswords": false, 113 | "id": "3c73f14f-5a01-4016-98bb-9605146a1a49", 114 | "name": "2.M5LLRUsBnTovXQuA4DBKLA==|ViL7ZxNENF6j28TjwwoHKN555BU9Wid75uvYyd0munE=|BIgdP+aizz0FrAJk5pTov4wbHME/Qm3GpJ0u1CgR/OE=", 115 | "object": "collectionDetails", 116 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 117 | "readOnly": false 118 | }, 119 | { 120 | "externalId": null, 121 | "hidePasswords": false, 122 | "id": "9ed17918-31f6-4ac5-ac82-c11541cd8a7c", 123 | "name": "2.ltxXSkSQ94FHxSwVlMBYUw==|wjvJW4JLgw9i9375ujVJnQ==|t2gLT6iyEPsgIlUedbZ+sPWOooGP1zONx6UOiPA4Dx8=", 124 | "object": "collectionDetails", 125 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 126 | "readOnly": false 127 | } 128 | ], 129 | "domains": null, 130 | "folders": [], 131 | "object": "sync", 132 | "policies": [], 133 | "profile": { 134 | "_status": 0, 135 | "avatarColor": null, 136 | "culture": "en-US", 137 | "email": "test-account@example.com", 138 | "emailVerified": true, 139 | "forcePasswordReset": false, 140 | "id": "a8be340c-856b-481f-8183-2b7712995da2", 141 | "key": "2.DTxwqo7MUUHE9e62TUO8aQ==|obupWKAMDnsQsTYsNw5vXRJromEdLoz86ApnaIK8xU1EdGX9MDfEmbLtDnS9lJbgiLn8m/lTCu/65sdm6Syv456y0k2xEahQr3jAbaaAXN8=|eHd5VPmgqxBf0sOGxmFMH2ESWnYKyiB6TgGx5SHZc1A=", 142 | "masterPasswordHint": null, 143 | "name": "Test Account", 144 | "object": "profile", 145 | "organizations": [ 146 | { 147 | "accessSecretsManager": false, 148 | "allowAdminAccessToAllCollectionItems": true, 149 | "enabled": true, 150 | "familySponsorshipAvailable": false, 151 | "familySponsorshipFriendlyName": null, 152 | "familySponsorshipLastSyncDate": null, 153 | "familySponsorshipToDelete": null, 154 | "familySponsorshipValidUntil": null, 155 | "flexibleCollections": false, 156 | "hasPublicAndPrivateKeys": true, 157 | "id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 158 | "identifier": null, 159 | "key": "4.ZGlK4NPuK2AcLMbjv6V28lOeZapVjuE/NIMl3IEigeJ7OyCRu2OUfx/N91AzVxdM1XhBOqNbe+eUAN8HBYBb4UJSLcO/XVHOPjfjsYybBuPCCTyVue9Z/4xLZGfq6ggt2NOY29xAwvmufGYfXweRMkVXzdK9C3RGBjPbZ4WS5nm4blss5XCQs1SakXfe0J3Su+hlkRRbdz0NeAx7C+wasyNbdGTJQu+1F7JuJWoX2aBJYu/ulPnX61cYO+PVdXPSLpypp8mjdIRgu2I3xU1puFT0pU6V2e0XE9mIKJA6eqmXRwkbSO9ij+jwshz6RB4HueB2nqyYqIYPEJVNKceK4g==", 160 | "keyConnectorEnabled": false, 161 | "keyConnectorUrl": null, 162 | "limitCollectionCreationDeletion": true, 163 | "maxCollections": 10, 164 | "maxStorageGb": 10, 165 | "name": "Test Organization", 166 | "object": "profileOrganization", 167 | "permissions": { 168 | "accessEventLogs": false, 169 | "accessImportExport": false, 170 | "accessReports": false, 171 | "createNewCollections": false, 172 | "deleteAnyCollection": false, 173 | "deleteAssignedCollections": false, 174 | "editAnyCollection": false, 175 | "editAssignedCollections": false, 176 | "manageGroups": false, 177 | "managePolicies": false, 178 | "manageResetPassword": false, 179 | "manageScim": false, 180 | "manageSso": false, 181 | "manageUsers": false 182 | }, 183 | "planProductType": 0, 184 | "providerId": null, 185 | "providerName": null, 186 | "providerType": null, 187 | "resetPasswordEnrolled": false, 188 | "seats": 10, 189 | "selfHost": true, 190 | "ssoBound": false, 191 | "status": 2, 192 | "type": 0, 193 | "use2fa": true, 194 | "useActivateAutofillPolicy": false, 195 | "useApi": true, 196 | "useCustomPermissions": false, 197 | "useDirectory": false, 198 | "useEvents": false, 199 | "useGroups": false, 200 | "useKeyConnector": false, 201 | "usePasswordManager": true, 202 | "usePolicies": true, 203 | "useResetPassword": false, 204 | "useScim": false, 205 | "useSecretsManager": false, 206 | "useSso": false, 207 | "useTotp": true, 208 | "userId": "a8be340c-856b-481f-8183-2b7712995da2", 209 | "usersGetPremium": true 210 | } 211 | ], 212 | "premium": true, 213 | "premiumFromOrganization": false, 214 | "privateKey": "2.spAwCfq3v5MzYTt0zb++bQ==|YYEJ0FXRBCAySl2KAjgsGVreD3/mBnYvL49NCvKRXe//f4Cr8hQyXwvZqCYl2tgUAxy08AyCxE5V5sCTXyxKee2WgArxLRLQHsmvrmSjZwTE5RJd8hBwVVMw073mowf+UW+gK7bli12Yy0yHNfIrNeVKgSoGVAm0v71TzQgGwOcbxdfSu2ovP7HYIypQ+BFl2tXb+zu1IYbLPEvhRYJTHUILr3mtm4M6B9TRw4A9CgPgLBe0V/QWubLrgoBijRRCN38xSXY4rIEI3SovqIITUEF3B3QC+/235iRppgurhOmuMZOqvLhoZrizYmxvyQwSKC6erF/j0KY7ujyP9tYNVV614aGI3cH10mwntmKdPGMstmbOb4xcDZFRI6mclVxcXlGlSg0c8oOacXQwTQ6m0EwBLXvsLkPGt6n8qLGB1EfdoY9B367GX5vrpThhL0txinTcG0p2ISOsD1vGXm9nuPTZWfR1hjy+xUNCe1ay/3TGRysyggA4mL9NOKeNs2RRZU0jr7IlqV/QN7Cr+dGZ74KRq2hv8cVR0JCsXgxcwlzeqUY2jo2iTe/MsXWfToMqLBhkFCLSl3AkuLfGn+ftGkI5xxyG4y9HZungJwrBksxjUBJnLd8jzxxz2HYgRA/AXqpsTHiD9CU2gKAc8oKQMLy6HShVUCzLALmhOgxxdQUpROLzq2NdtTThqWLxdFkzLxOOBONaEA0LEuXGh6ooLsubj5RUC0fK84WsKShqdyjeZx/H0Eze2c2V39Aru9yQlMjpXSyKHFWGb9e3QAKdC37zX6ajka+qu3dAGQyELCUydD1lpPEt6+m/Qy5nUdkEphnqRx5ZvEtSnU+CMKmq4C7t4Kj/HF8AHLBmnvsozxQp+hmGVkF/JzdzXhUUHeQwNtP7YcgA4Z0FRjxb+pEqaHOjrYVXl0PDzRNc8VxwS5jvWv2Pu1Pu0aBUJYt/EAHicmUxZcCLHsjHTB5trRpT3ttorkrce5DDdBTpiF7NR87SKg+my6ohvzHzhkFXuvuHzy9Kh8KwOh44sInNyQOn7w+Yoja2O0i9NXN+esFlhDTIhKQ1KFfFQAJ3yeGgpRoLLSpxEzSoslyEIdmZbFPnlWwcsVToEOf3BdXgR8G2lFr1zL44WyBUtL2ESufxIVYcs5rc+VELFkRVaaUSQ8XHVYG81GZYcD3eXxRIHiJXEp91l36Toao8JJMW5kjmJy4uVuSZA+/pdnev7lISXP9+L+BcNU5udmQ1n2ZfvIqHLnPdnKbuyKjsaY2CwQt6bqBlo6/jHj8tCoD0ux26EPobUIY5kLVEhsKBrXO9NRdHF4kH6KkkJ6P3UBctm7s3UJ5PK9LT0ORJV5ssIdTiAny7oy8AaSx4xxJYZVYLbREzUy0elsCvAV31U0slAYlyeDMTdoXy4nOlYuWMsdWSsJMCcNCZoI9cU49Z2LFGZlJeNjUugPgHBpkSemMC7gwbIRnLG/klOrBzdK8wQ06N9Ee7uyh1i6eIq6eCro+t8T1bdWebPn9vITNKUW6Mx1tBeEsuGh1zIf8h2Oyp8RfosJJxm4SwFTrvNfocIntD9DCQ8FaUvANYnVNQVe0uII0C7LMpmNpZ53wX77ccgW82c0KJjdEqkivNbkvvZj0Dn6jeXZw=|vEnM4IsDD47rWIndjXlmmMqfzhAKa98iWwPeiln6S6s=", 215 | "providerOrganizations": [], 216 | "providers": [], 217 | "securityStamp": "f5bffd6f-bb08-4469-962a-3f96810bd56e", 218 | "twoFactorEnabled": false, 219 | "usesKeyConnector": false 220 | }, 221 | "sends": [], 222 | "unofficialServer": true 223 | } -------------------------------------------------------------------------------- /tests/fixtures/test-account/sync_pascal.json: -------------------------------------------------------------------------------- 1 | { 2 | "Ciphers": [ 3 | { 4 | "Attachments": null, 5 | "Card": null, 6 | "CollectionIds": [], 7 | "CreationDate": "2024-07-23T09:45:02.427052Z", 8 | "Data": { 9 | "Fields": null, 10 | "Name": "2.7+F6j8lp/fLGquyYCucJmQ==|EAvNo1z+agjIiQbpwb38yQ==|G8FVWnxcZjMqPcKVStnWpUWkkgs2kY8m8IcYgRJ7CR8=", 11 | "Notes": null, 12 | "PasswordHistory": null, 13 | "Uri": null, 14 | "autofillOnPageLoad": null, 15 | "password": "2.hRIeQDJ3R3T8ioQ9fZe/QA==|0oEy7d+s/7rbd3yRh603OA==|9wR6eB42YTsHGzS4Bxqpq0II8uAJWmh2cUrk3TJMOUQ=", 16 | "passwordRevisionDate": null, 17 | "totp": null, 18 | "uris": [], 19 | "username": "2.AwjnfebCr1/I+wC28tn0nw==|HOfQmbfcvs+NjBZAs5gC7Q==|PlGBYM4Mrkfi3drSv0txw0tFLEsd0JYl3ZLotkXuTuM=" 20 | }, 21 | "DeletedDate": null, 22 | "Edit": true, 23 | "Favorite": false, 24 | "Fields": null, 25 | "FolderId": null, 26 | "Id": "921b94a6-d270-4889-88c2-c2531054c02e", 27 | "Identity": null, 28 | "Key": null, 29 | "Login": { 30 | "Uri": null, 31 | "autofillOnPageLoad": null, 32 | "password": "2.hRIeQDJ3R3T8ioQ9fZe/QA==|0oEy7d+s/7rbd3yRh603OA==|9wR6eB42YTsHGzS4Bxqpq0II8uAJWmh2cUrk3TJMOUQ=", 33 | "passwordRevisionDate": null, 34 | "totp": null, 35 | "uris": [], 36 | "username": "2.AwjnfebCr1/I+wC28tn0nw==|HOfQmbfcvs+NjBZAs5gC7Q==|PlGBYM4Mrkfi3drSv0txw0tFLEsd0JYl3ZLotkXuTuM=" 37 | }, 38 | "Name": "2.7+F6j8lp/fLGquyYCucJmQ==|EAvNo1z+agjIiQbpwb38yQ==|G8FVWnxcZjMqPcKVStnWpUWkkgs2kY8m8IcYgRJ7CR8=", 39 | "Notes": null, 40 | "Object": "cipherDetails", 41 | "OrganizationId": null, 42 | "OrganizationUseTotp": true, 43 | "PasswordHistory": null, 44 | "Reprompt": 0, 45 | "RevisionDate": "2024-07-23T09:45:02.427261Z", 46 | "SecureNote": null, 47 | "Type": 1, 48 | "ViewPassword": true 49 | }, 50 | { 51 | "Attachments": null, 52 | "Card": null, 53 | "CollectionIds": [ 54 | "3c73f14f-5a01-4016-98bb-9605146a1a49" 55 | ], 56 | "CreationDate": "2024-07-23T09:40:50.678852Z", 57 | "Data": { 58 | "Fields": null, 59 | "Name": "2.YFrZrHpUErMukhH02PpBJg==|euAdV2V6x6RhKRRDQ5DgRg==|MEu8r16SaQVtPTSpt3uPkYQ5saAmgGpRwLzZv64nDoI=", 60 | "Notes": null, 61 | "PasswordHistory": null, 62 | "Uri": null, 63 | "autofillOnPageLoad": null, 64 | "password": "2.XaBC/gN/6A8rZBs82lnyZg==|XKpgx5euzvNrNcweWhOLtA==|4jsrMTGChg5Eh5U4nQiS5fpo9dKY5s7P39mWSSNl2a4=", 65 | "passwordRevisionDate": null, 66 | "totp": null, 67 | "uris": [], 68 | "username": "2.AwEPZzhBWbjdO3tmLsrI0A==|9WrHrtPiiGgtRXU23y7bmw==|BehLMa8tKqDU52jZDS4sktsbF3owXsL4ZWGjGchj/kY=" 69 | }, 70 | "DeletedDate": null, 71 | "Edit": true, 72 | "Favorite": false, 73 | "Fields": null, 74 | "FolderId": null, 75 | "Id": "fc246fe5-9177-455b-b318-c00fab407dc8", 76 | "Identity": null, 77 | "Key": null, 78 | "Login": { 79 | "Uri": null, 80 | "autofillOnPageLoad": null, 81 | "password": "2.XaBC/gN/6A8rZBs82lnyZg==|XKpgx5euzvNrNcweWhOLtA==|4jsrMTGChg5Eh5U4nQiS5fpo9dKY5s7P39mWSSNl2a4=", 82 | "passwordRevisionDate": null, 83 | "totp": null, 84 | "uris": [], 85 | "username": "2.AwEPZzhBWbjdO3tmLsrI0A==|9WrHrtPiiGgtRXU23y7bmw==|BehLMa8tKqDU52jZDS4sktsbF3owXsL4ZWGjGchj/kY=" 86 | }, 87 | "Name": "2.YFrZrHpUErMukhH02PpBJg==|euAdV2V6x6RhKRRDQ5DgRg==|MEu8r16SaQVtPTSpt3uPkYQ5saAmgGpRwLzZv64nDoI=", 88 | "Notes": null, 89 | "Object": "cipherDetails", 90 | "OrganizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 91 | "OrganizationUseTotp": true, 92 | "PasswordHistory": null, 93 | "Reprompt": 0, 94 | "RevisionDate": "2024-07-23T09:40:50.679370Z", 95 | "SecureNote": null, 96 | "Type": 1, 97 | "ViewPassword": true 98 | } 99 | ], 100 | "Collections": [ 101 | { 102 | "ExternalId": null, 103 | "HidePasswords": false, 104 | "Id": "10370e0f-c916-4ead-9767-c4d75d0ef1f3", 105 | "Name": "2.UFQ61Bp4hihu31h+WqjjCw==|poUtkoWSw+INpaxsnMp6g5ETt+v0lWNV9rXvxRLx6b8=|AEQzWIqJYoNQ0+ntzdqA76/wsxe4C0SVRS8yz/pio+w=", 106 | "Object": "collectionDetails", 107 | "OrganizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 108 | "ReadOnly": false 109 | }, 110 | { 111 | "ExternalId": null, 112 | "HidePasswords": false, 113 | "Id": "3c73f14f-5a01-4016-98bb-9605146a1a49", 114 | "Name": "2.M5LLRUsBnTovXQuA4DBKLA==|ViL7ZxNENF6j28TjwwoHKN555BU9Wid75uvYyd0munE=|BIgdP+aizz0FrAJk5pTov4wbHME/Qm3GpJ0u1CgR/OE=", 115 | "Object": "collectionDetails", 116 | "OrganizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 117 | "ReadOnly": false 118 | }, 119 | { 120 | "ExternalId": null, 121 | "HidePasswords": false, 122 | "Id": "9ed17918-31f6-4ac5-ac82-c11541cd8a7c", 123 | "Name": "2.ltxXSkSQ94FHxSwVlMBYUw==|wjvJW4JLgw9i9375ujVJnQ==|t2gLT6iyEPsgIlUedbZ+sPWOooGP1zONx6UOiPA4Dx8=", 124 | "Object": "collectionDetails", 125 | "OrganizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 126 | "ReadOnly": false 127 | } 128 | ], 129 | "Domains": null, 130 | "Folders": [], 131 | "Object": "sync", 132 | "Policies": [], 133 | "Profile": { 134 | "AvatarColor": null, 135 | "Culture": "en-US", 136 | "Email": "test-account@example.com", 137 | "EmailVerified": true, 138 | "ForcePasswordReset": false, 139 | "Id": "a8be340c-856b-481f-8183-2b7712995da2", 140 | "Key": "2.DTxwqo7MUUHE9e62TUO8aQ==|obupWKAMDnsQsTYsNw5vXRJromEdLoz86ApnaIK8xU1EdGX9MDfEmbLtDnS9lJbgiLn8m/lTCu/65sdm6Syv456y0k2xEahQr3jAbaaAXN8=|eHd5VPmgqxBf0sOGxmFMH2ESWnYKyiB6TgGx5SHZc1A=", 141 | "MasterPasswordHint": null, 142 | "Name": "Test Account", 143 | "Object": "profile", 144 | "Organizations": [ 145 | { 146 | "Enabled": true, 147 | "HasPublicAndPrivateKeys": true, 148 | "Id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 149 | "Identifier": null, 150 | "Key": "4.ZGlK4NPuK2AcLMbjv6V28lOeZapVjuE/NIMl3IEigeJ7OyCRu2OUfx/N91AzVxdM1XhBOqNbe+eUAN8HBYBb4UJSLcO/XVHOPjfjsYybBuPCCTyVue9Z/4xLZGfq6ggt2NOY29xAwvmufGYfXweRMkVXzdK9C3RGBjPbZ4WS5nm4blss5XCQs1SakXfe0J3Su+hlkRRbdz0NeAx7C+wasyNbdGTJQu+1F7JuJWoX2aBJYu/ulPnX61cYO+PVdXPSLpypp8mjdIRgu2I3xU1puFT0pU6V2e0XE9mIKJA6eqmXRwkbSO9ij+jwshz6RB4HueB2nqyYqIYPEJVNKceK4g==", 151 | "MaxCollections": 10, 152 | "MaxStorageGb": 10, 153 | "Name": "Test Organization", 154 | "Object": "profileOrganization", 155 | "ProviderId": null, 156 | "ProviderName": null, 157 | "ResetPasswordEnrolled": false, 158 | "Seats": 10, 159 | "SelfHost": true, 160 | "SsoBound": false, 161 | "Status": 2, 162 | "Type": 0, 163 | "Use2fa": true, 164 | "UseApi": true, 165 | "UseDirectory": false, 166 | "UseEvents": false, 167 | "UseGroups": false, 168 | "UsePolicies": true, 169 | "UseResetPassword": false, 170 | "UseSso": false, 171 | "UseTotp": true, 172 | "UserId": "a8be340c-856b-481f-8183-2b7712995da2", 173 | "UsersGetPremium": true 174 | } 175 | ], 176 | "Premium": true, 177 | "PrivateKey": "2.spAwCfq3v5MzYTt0zb++bQ==|YYEJ0FXRBCAySl2KAjgsGVreD3/mBnYvL49NCvKRXe//f4Cr8hQyXwvZqCYl2tgUAxy08AyCxE5V5sCTXyxKee2WgArxLRLQHsmvrmSjZwTE5RJd8hBwVVMw073mowf+UW+gK7bli12Yy0yHNfIrNeVKgSoGVAm0v71TzQgGwOcbxdfSu2ovP7HYIypQ+BFl2tXb+zu1IYbLPEvhRYJTHUILr3mtm4M6B9TRw4A9CgPgLBe0V/QWubLrgoBijRRCN38xSXY4rIEI3SovqIITUEF3B3QC+/235iRppgurhOmuMZOqvLhoZrizYmxvyQwSKC6erF/j0KY7ujyP9tYNVV614aGI3cH10mwntmKdPGMstmbOb4xcDZFRI6mclVxcXlGlSg0c8oOacXQwTQ6m0EwBLXvsLkPGt6n8qLGB1EfdoY9B367GX5vrpThhL0txinTcG0p2ISOsD1vGXm9nuPTZWfR1hjy+xUNCe1ay/3TGRysyggA4mL9NOKeNs2RRZU0jr7IlqV/QN7Cr+dGZ74KRq2hv8cVR0JCsXgxcwlzeqUY2jo2iTe/MsXWfToMqLBhkFCLSl3AkuLfGn+ftGkI5xxyG4y9HZungJwrBksxjUBJnLd8jzxxz2HYgRA/AXqpsTHiD9CU2gKAc8oKQMLy6HShVUCzLALmhOgxxdQUpROLzq2NdtTThqWLxdFkzLxOOBONaEA0LEuXGh6ooLsubj5RUC0fK84WsKShqdyjeZx/H0Eze2c2V39Aru9yQlMjpXSyKHFWGb9e3QAKdC37zX6ajka+qu3dAGQyELCUydD1lpPEt6+m/Qy5nUdkEphnqRx5ZvEtSnU+CMKmq4C7t4Kj/HF8AHLBmnvsozxQp+hmGVkF/JzdzXhUUHeQwNtP7YcgA4Z0FRjxb+pEqaHOjrYVXl0PDzRNc8VxwS5jvWv2Pu1Pu0aBUJYt/EAHicmUxZcCLHsjHTB5trRpT3ttorkrce5DDdBTpiF7NR87SKg+my6ohvzHzhkFXuvuHzy9Kh8KwOh44sInNyQOn7w+Yoja2O0i9NXN+esFlhDTIhKQ1KFfFQAJ3yeGgpRoLLSpxEzSoslyEIdmZbFPnlWwcsVToEOf3BdXgR8G2lFr1zL44WyBUtL2ESufxIVYcs5rc+VELFkRVaaUSQ8XHVYG81GZYcD3eXxRIHiJXEp91l36Toao8JJMW5kjmJy4uVuSZA+/pdnev7lISXP9+L+BcNU5udmQ1n2ZfvIqHLnPdnKbuyKjsaY2CwQt6bqBlo6/jHj8tCoD0ux26EPobUIY5kLVEhsKBrXO9NRdHF4kH6KkkJ6P3UBctm7s3UJ5PK9LT0ORJV5ssIdTiAny7oy8AaSx4xxJYZVYLbREzUy0elsCvAV31U0slAYlyeDMTdoXy4nOlYuWMsdWSsJMCcNCZoI9cU49Z2LFGZlJeNjUugPgHBpkSemMC7gwbIRnLG/klOrBzdK8wQ06N9Ee7uyh1i6eIq6eCro+t8T1bdWebPn9vITNKUW6Mx1tBeEsuGh1zIf8h2Oyp8RfosJJxm4SwFTrvNfocIntD9DCQ8FaUvANYnVNQVe0uII0C7LMpmNpZ53wX77ccgW82c0KJjdEqkivNbkvvZj0Dn6jeXZw=|vEnM4IsDD47rWIndjXlmmMqfzhAKa98iWwPeiln6S6s=", 178 | "ProviderOrganizations": [], 179 | "Providers": [], 180 | "SecurityStamp": "f5bffd6f-bb08-4469-962a-3f96810bd56e", 181 | "TwoFactorEnabled": false, 182 | "_Status": 0 183 | }, 184 | "Sends": [], 185 | "unofficialServer": true 186 | } -------------------------------------------------------------------------------- /tests/fixtures/test-organization/collections/collections_camel.json: -------------------------------------------------------------------------------- 1 | { 2 | "continuationToken": null, 3 | "data": [ 4 | { 5 | "externalId": null, 6 | "id": "10370e0f-c916-4ead-9767-c4d75d0ef1f3", 7 | "name": "2.UFQ61Bp4hihu31h+WqjjCw==|poUtkoWSw+INpaxsnMp6g5ETt+v0lWNV9rXvxRLx6b8=|AEQzWIqJYoNQ0+ntzdqA76/wsxe4C0SVRS8yz/pio+w=", 8 | "object": "collection", 9 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0" 10 | }, 11 | { 12 | "externalId": null, 13 | "id": "9ed17918-31f6-4ac5-ac82-c11541cd8a7c", 14 | "name": "2.ltxXSkSQ94FHxSwVlMBYUw==|wjvJW4JLgw9i9375ujVJnQ==|t2gLT6iyEPsgIlUedbZ+sPWOooGP1zONx6UOiPA4Dx8=", 15 | "object": "collection", 16 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0" 17 | }, 18 | { 19 | "externalId": null, 20 | "id": "3c73f14f-5a01-4016-98bb-9605146a1a49", 21 | "name": "2.M5LLRUsBnTovXQuA4DBKLA==|ViL7ZxNENF6j28TjwwoHKN555BU9Wid75uvYyd0munE=|BIgdP+aizz0FrAJk5pTov4wbHME/Qm3GpJ0u1CgR/OE=", 22 | "object": "collection", 23 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0" 24 | } 25 | ], 26 | "object": "list" 27 | } -------------------------------------------------------------------------------- /tests/fixtures/test-organization/collections/collections_pascal.json: -------------------------------------------------------------------------------- 1 | { 2 | "ContinuationToken": null, 3 | "Data": [ 4 | { 5 | "ExternalId": null, 6 | "Id": "10370e0f-c916-4ead-9767-c4d75d0ef1f3", 7 | "Name": "2.UFQ61Bp4hihu31h+WqjjCw==|poUtkoWSw+INpaxsnMp6g5ETt+v0lWNV9rXvxRLx6b8=|AEQzWIqJYoNQ0+ntzdqA76/wsxe4C0SVRS8yz/pio+w=", 8 | "Object": "collection", 9 | "OrganizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0" 10 | }, 11 | { 12 | "ExternalId": null, 13 | "Id": "9ed17918-31f6-4ac5-ac82-c11541cd8a7c", 14 | "Name": "2.ltxXSkSQ94FHxSwVlMBYUw==|wjvJW4JLgw9i9375ujVJnQ==|t2gLT6iyEPsgIlUedbZ+sPWOooGP1zONx6UOiPA4Dx8=", 15 | "Object": "collection", 16 | "OrganizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0" 17 | }, 18 | { 19 | "ExternalId": null, 20 | "Id": "3c73f14f-5a01-4016-98bb-9605146a1a49", 21 | "Name": "2.M5LLRUsBnTovXQuA4DBKLA==|ViL7ZxNENF6j28TjwwoHKN555BU9Wid75uvYyd0munE=|BIgdP+aizz0FrAJk5pTov4wbHME/Qm3GpJ0u1CgR/OE=", 22 | "Object": "collection", 23 | "OrganizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0" 24 | } 25 | ], 26 | "Object": "list" 27 | } -------------------------------------------------------------------------------- /tests/fixtures/test-organization/collections/test-collection-2/details_camel.json: -------------------------------------------------------------------------------- 1 | { 2 | "assigned": true, 3 | "externalId": null, 4 | "groups": [], 5 | "id": "3c73f14f-5a01-4016-98bb-9605146a1a49", 6 | "name": "2.M5LLRUsBnTovXQuA4DBKLA==|ViL7ZxNENF6j28TjwwoHKN555BU9Wid75uvYyd0munE=|BIgdP+aizz0FrAJk5pTov4wbHME/Qm3GpJ0u1CgR/OE=", 7 | "object": "collectionAccessDetails", 8 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 9 | "users": [ 10 | { 11 | "hidePasswords": false, 12 | "id": "7f009002-3a23-4880-985c-d9c351192820", 13 | "readOnly": true 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /tests/fixtures/test-organization/collections/test-collection-2/users_camel.json: -------------------------------------------------------------------------------- 1 | [{"hidePasswords":false,"id":"7f009002-3a23-4880-985c-d9c351192820","readOnly":true}] -------------------------------------------------------------------------------- /tests/fixtures/test-organization/collections/test-collection/details_camel.json: -------------------------------------------------------------------------------- 1 | { 2 | "assigned": true, 3 | "externalId": null, 4 | "groups": [], 5 | "id": "9ed17918-31f6-4ac5-ac82-c11541cd8a7c", 6 | "name": "2.ltxXSkSQ94FHxSwVlMBYUw==|wjvJW4JLgw9i9375ujVJnQ==|t2gLT6iyEPsgIlUedbZ+sPWOooGP1zONx6UOiPA4Dx8=", 7 | "object": "collectionAccessDetails", 8 | "organizationId": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 9 | "users": [] 10 | } -------------------------------------------------------------------------------- /tests/fixtures/test-organization/collections/test-collection/users_camel.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /tests/fixtures/test-organization/organization_camel.json: -------------------------------------------------------------------------------- 1 | { 2 | "billingEmail": "test-account@example.com", 3 | "businessAddress1": null, 4 | "businessAddress2": null, 5 | "businessAddress3": null, 6 | "businessCountry": null, 7 | "businessName": null, 8 | "businessTaxNumber": null, 9 | "hasPublicAndPrivateKeys": true, 10 | "id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 11 | "identifier": null, 12 | "maxCollections": 10, 13 | "maxStorageGb": 10, 14 | "name": "Test Organization", 15 | "object": "organization", 16 | "plan": "TeamsAnnually", 17 | "planType": 5, 18 | "seats": 10, 19 | "selfHost": true, 20 | "use2fa": true, 21 | "useApi": true, 22 | "useDirectory": false, 23 | "useEvents": false, 24 | "useGroups": false, 25 | "usePolicies": true, 26 | "useResetPassword": false, 27 | "useSso": false, 28 | "useTotp": true, 29 | "usersGetPremium": true 30 | } -------------------------------------------------------------------------------- /tests/fixtures/test-organization/organization_pascal.json: -------------------------------------------------------------------------------- 1 | { 2 | "BillingEmail": "test-account@example.com", 3 | "BusinessAddress1": null, 4 | "BusinessAddress2": null, 5 | "BusinessAddress3": null, 6 | "BusinessCountry": null, 7 | "BusinessName": null, 8 | "BusinessTaxNumber": null, 9 | "HasPublicAndPrivateKeys": true, 10 | "Id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0", 11 | "Identifier": null, 12 | "MaxCollections": 10, 13 | "MaxStorageGb": 10, 14 | "Name": "Test Organization", 15 | "Object": "organization", 16 | "Plan": "TeamsAnnually", 17 | "PlanType": 5, 18 | "Seats": 10, 19 | "SelfHost": true, 20 | "Use2fa": true, 21 | "UseApi": true, 22 | "UseDirectory": false, 23 | "UseEvents": false, 24 | "UseGroups": false, 25 | "UsePolicies": true, 26 | "UseResetPassword": false, 27 | "UseSso": false, 28 | "UseTotp": true, 29 | "UsersGetPremium": true 30 | } -------------------------------------------------------------------------------- /tests/fixtures/test-organization/users_camel.json: -------------------------------------------------------------------------------- 1 | { 2 | "continuationToken": null, 3 | "data": [ 4 | { 5 | "accessAll": true, 6 | "collections": [], 7 | "email": "test-account@example.com", 8 | "externalId": null, 9 | "groups": [], 10 | "id": "44f9833c-33dd-461c-a691-563115724e55", 11 | "name": "Test Account", 12 | "object": "organizationUserUserDetails", 13 | "resetPasswordEnrolled": false, 14 | "status": 2, 15 | "twoFactorEnabled": false, 16 | "type": 0, 17 | "userId": "a8be340c-856b-481f-8183-2b7712995da2" 18 | }, 19 | { 20 | "accessAll": false, 21 | "collections": [ 22 | { 23 | "hidePasswords": false, 24 | "id": "3c73f14f-5a01-4016-98bb-9605146a1a49", 25 | "readOnly": true 26 | } 27 | ], 28 | "email": "test-account-2@example.com", 29 | "externalId": null, 30 | "groups": [], 31 | "id": "7f009002-3a23-4880-985c-d9c351192820", 32 | "name": "Test Account 2", 33 | "object": "organizationUserUserDetails", 34 | "resetPasswordEnrolled": false, 35 | "status": 2, 36 | "twoFactorEnabled": false, 37 | "type": 2, 38 | "userId": "cd95d118-e96d-4b8d-a000-a10c92dd8f88" 39 | } 40 | ], 41 | "object": "list" 42 | } -------------------------------------------------------------------------------- /tests/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numberly/python-vaultwarden/964e13b708a9b3c4f8e7c6352db41506a88ecff1/tests/models/__init__.py -------------------------------------------------------------------------------- /tests/models/validation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numberly/python-vaultwarden/964e13b708a9b3c4f8e7c6352db41506a88ecff1/tests/models/validation/__init__.py -------------------------------------------------------------------------------- /tests/models/validation/test_bitwarden_models.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from pydantic import TypeAdapter 4 | 5 | from vaultwarden.models.bitwarden import ( 6 | Organization, 7 | ResplistBitwarden, 8 | OrganizationUserDetails, 9 | CollectionUser, 10 | ) 11 | 12 | 13 | class TestBitwardenModels(unittest.TestCase): 14 | @staticmethod 15 | def read_json_payload(file_path): 16 | with open(file_path, "r") as file: 17 | return file.read() 18 | 19 | def test_organization(self): 20 | payload = self.read_json_payload( 21 | "tests/fixtures/test-organization/organization_camel.json" 22 | ) 23 | data = Organization.model_validate_json(payload) 24 | assert data.Name == "Test Organization" 25 | 26 | def test_organization_users(self): 27 | payload = self.read_json_payload( 28 | "tests/fixtures/test-organization/users_camel.json" 29 | ) 30 | users = ( 31 | ResplistBitwarden[OrganizationUserDetails] 32 | .model_validate_json( 33 | payload, 34 | context={"parent_id": "cda840d2-1de0-4f31-bd49-b30dacd7e8b0"}, 35 | ) 36 | .model_validate_json(payload) 37 | ) 38 | assert len(users.Data) == 2 39 | assert users.Data[0].Email == "test-account@example.com" 40 | assert users.Data[1].Email == "test-account-2@example.com" 41 | 42 | def test_organization_collections(self): 43 | payload1 = self.read_json_payload( 44 | "tests/fixtures/test-organization/collections/test-collection/users_camel.json" 45 | ) 46 | payload2 = self.read_json_payload( 47 | "tests/fixtures/test-organization/collections/test-collection-2/users_camel.json" 48 | ) 49 | collection1 = TypeAdapter(list[CollectionUser]).validate_json( 50 | payload1, 51 | context={"parent_id": "9ed17918-31f6-4ac5-ac82-c11541cd8a7c"}, 52 | ) 53 | collection2 = TypeAdapter(list[CollectionUser]).validate_json( 54 | payload2, 55 | context={"parent_id": "3c73f14f-5a01-4016-98bb-9605146a1a49"}, 56 | ) 57 | 58 | assert len(collection1) == 0 59 | assert len(collection2) == 1 60 | 61 | 62 | if __name__ == "__main__": 63 | unittest.main() 64 | -------------------------------------------------------------------------------- /tests/models/validation/test_pascal_camel_cases.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from pydantic import TypeAdapter 4 | 5 | from src.vaultwarden.models.sync import SyncData, VaultwardenUser 6 | from vaultwarden.models.bitwarden import ( 7 | Organization, 8 | ResplistBitwarden, 9 | OrganizationCollection, 10 | ) 11 | 12 | 13 | class TestModelCases(unittest.TestCase): 14 | @staticmethod 15 | def read_json_payload(file_path): 16 | with open(file_path, "r") as file: 17 | return file.read() 18 | 19 | def test_organization(self): 20 | pascal_case_payload = self.read_json_payload( 21 | "tests/fixtures/test-organization/organization_pascal.json" 22 | ) 23 | camel_case_payload = self.read_json_payload( 24 | "tests/fixtures/test-organization/organization_camel.json" 25 | ) 26 | pascal = Organization.model_validate_json(pascal_case_payload) 27 | camel = Organization.model_validate_json(camel_case_payload) 28 | self.assertEqual(pascal.Name, camel.Name) 29 | 30 | def test_collections(self): 31 | pascal_case_payload = self.read_json_payload( 32 | "tests/fixtures/test-organization/collections/collections_pascal.json" 33 | ) 34 | pascal_collections = ( 35 | ResplistBitwarden[OrganizationCollection] 36 | .model_validate_json(pascal_case_payload) 37 | .Data 38 | ) 39 | camel_case_payload = self.read_json_payload( 40 | "tests/fixtures/test-organization/collections/collections_camel.json" 41 | ) 42 | camel_collections = ( 43 | ResplistBitwarden[OrganizationCollection] 44 | .model_validate_json(camel_case_payload) 45 | .Data 46 | ) 47 | self.assertEqual(len(pascal_collections), len(camel_collections)) 48 | self.assertEqual(pascal_collections[0].Name, camel_collections[0].Name) 49 | self.assertEqual(pascal_collections[1].Name, camel_collections[1].Name) 50 | 51 | def test_sync_data(self): 52 | pascal_case_payload = self.read_json_payload( 53 | "tests/fixtures/test-account/sync_pascal.json" 54 | ) 55 | camel_case_payload = self.read_json_payload( 56 | "tests/fixtures/test-account/sync_camel.json" 57 | ) 58 | pascal = SyncData.model_validate_json(pascal_case_payload) 59 | camel = SyncData.model_validate_json(camel_case_payload) 60 | self.assertEqual(len(pascal.Ciphers), len(camel.Ciphers)) 61 | self.assertEqual(len(pascal.Collections), len(camel.Collections)) 62 | self.assertEqual( 63 | pascal.Collections[0].get("Name"), camel.Collections[0].get("name") 64 | ) 65 | self.assertEqual( 66 | pascal.Collections[1].get("Name"), camel.Collections[1].get("name") 67 | ) 68 | 69 | def test_admin_users(self): 70 | pascal_case_payload = self.read_json_payload( 71 | "tests/fixtures/admin/users_pascal.json" 72 | ) 73 | camel_case_payload = self.read_json_payload( 74 | "tests/fixtures/admin/users_camel.json" 75 | ) 76 | pascal = TypeAdapter(list[VaultwardenUser]).validate_json( 77 | pascal_case_payload 78 | ) 79 | camel = TypeAdapter(list[VaultwardenUser]).validate_json( 80 | camel_case_payload 81 | ) 82 | self.assertEqual(len(pascal), len(camel)) 83 | self.assertEqual(pascal[0].Name, camel[0].Name) 84 | self.assertEqual(pascal[1].Name, camel[1].Name) 85 | self.assertEqual(pascal[0].Email, camel[0].Email) 86 | self.assertEqual(pascal[1].Email, camel[1].Email) 87 | self.assertEqual(pascal[0].UserEnabled, camel[0].UserEnabled) 88 | self.assertEqual(pascal[1].UserEnabled, camel[1].UserEnabled) 89 | 90 | 91 | if __name__ == "__main__": 92 | unittest.main() 93 | -------------------------------------------------------------------------------- /tests/models/validation/test_sync_models.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from vaultwarden.models.sync import SyncData 4 | 5 | 6 | class TestSyncModels(unittest.TestCase): 7 | @staticmethod 8 | def read_json_payload(file_path): 9 | with open(file_path, "r") as file: 10 | return file.read() 11 | 12 | def test_syncdata(self): 13 | payload = self.read_json_payload( 14 | "tests/fixtures/test-account/sync_camel.json" 15 | ) 16 | data = SyncData.model_validate_json(payload) 17 | assert len(data.Ciphers) == 2 18 | assert len(data.Collections) == 3 19 | assert len(data.Profile.Organizations) == 1 20 | assert data.Profile.Organizations[0].Name == "Test Organization" 21 | assert len(data.Ciphers) == 2 22 | assert data.Profile.Email == "test-account@example.com" 23 | 24 | 25 | if __name__ == "__main__": 26 | unittest.main() 27 | -------------------------------------------------------------------------------- /tests/models/validation/test_vaultwarden_models.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from pydantic import TypeAdapter 4 | 5 | from vaultwarden.models.sync import VaultwardenUser 6 | 7 | 8 | class TestVaultwardenModels(unittest.TestCase): 9 | @staticmethod 10 | def read_json_payload(file_path): 11 | with open(file_path, "r") as file: 12 | return file.read() 13 | 14 | def test_users(self): 15 | payload = self.read_json_payload( 16 | "tests/fixtures/admin/users_camel.json" 17 | ) 18 | data = TypeAdapter(list[VaultwardenUser]).validate_json(payload) 19 | assert len(data) == 2 20 | assert data[0].Email == "test-account@example.com" 21 | assert data[1].Email == "test-account-2@example.com" 22 | assert data[0].Name == "Test Account" 23 | assert data[1].Name == "Test Account 2" 24 | assert data[0].UserEnabled 25 | assert data[1].UserEnabled 26 | 27 | 28 | if __name__ == "__main__": 29 | unittest.main() 30 | -------------------------------------------------------------------------------- /tests/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numberly/python-vaultwarden/964e13b708a9b3c4f8e7c6352db41506a88ecff1/tests/utils/__init__.py --------------------------------------------------------------------------------