From b7befd781e95694108a6317a58c60ffb7a7a5af4 Mon Sep 17 00:00:00 2001 From: td Date: Fri, 22 Mar 2024 21:24:21 +0530 Subject: [PATCH] chore: git mv --- .github/ISSUE_TEMPLATE/bug-report.yml | 71 - .github/ISSUE_TEMPLATE/config.yml | 1 - .github/ISSUE_TEMPLATE/epic.yml | 32 - .github/ISSUE_TEMPLATE/feature.yml | 47 - .github/ISSUE_TEMPLATE/improvement.yml | 47 - .github/workflows/general.yml | 25 - .github/workflows/issue-triage.yml | 18 - .github/workflows/publish.yml | 13 - .github/workflows/versions.env | 2 - .gitignore | 80 - .gitlab-ci.yml | 38 - CHANGELOG.md | 242 --- CONTRIBUTING.md | 37 - LICENSE | 21 - README.md | 49 - analysis_options.yaml | 21 - example/matrix_api_lite_example.dart | 8 - .../generated/api.dart | 0 .../generated/fixed_model.dart | 0 .../generated/internal.dart | 0 .../generated/model.dart | 0 .../generated/model.g.dart | 0 lib/{src => matrix_api_lite}/matrix_api.dart | 0 .../model/algorithm_types.dart | 0 .../model/auth/authentication_data.dart | 0 .../model/auth/authentication_identifier.dart | 0 .../model/auth/authentication_password.dart | 0 .../auth/authentication_phone_identifier.dart | 0 .../model/auth/authentication_recaptcha.dart | 0 ...authentication_third_party_identifier.dart | 0 .../auth/authentication_three_pid_creds.dart | 0 .../model/auth/authentication_token.dart | 0 .../model/auth/authentication_types.dart | 0 .../auth/authentication_user_identifier.dart | 0 .../model/basic_event.dart | 0 .../model/basic_event_with_sender.dart | 0 .../model/basic_room_event.dart | 0 .../model/children_state.dart | 0 .../model/event_types.dart | 0 .../events/forwarded_room_key_content.dart | 0 .../model/events/image_pack_content.dart | 0 .../model/events/olm_plaintext_payload.dart | 0 .../model/events/room_encrypted_content.dart | 0 .../model/events/room_encryption_content.dart | 0 .../model/events/room_key_content.dart | 0 .../events/room_key_request_content.dart | 0 .../secret_storage_default_key_content.dart | 0 .../events/secret_storage_key_content.dart | 0 .../model/events/tombstone_content.dart | 0 .../model/matrix_connection_exception.dart | 0 .../model/matrix_event.dart | 0 .../model/matrix_exception.dart | 0 .../model/matrix_keys.dart | 0 .../model/message_types.dart | 0 .../model/presence.dart | 0 .../model/presence_content.dart | 0 .../model/room_creation_types.dart | 0 .../model/room_keys_keys.dart | 0 .../model/room_summary.dart | 0 .../model/room_types.dart | 0 .../model/stripped_state_event.dart | 0 .../model/sync_update.dart | 0 .../utils/filter_map_extension.dart | 0 lib/{src => matrix_api_lite}/utils/logs.dart | 0 .../utils/map_copy_extension.dart | 0 .../utils/print_logs_native.dart | 0 .../utils/print_logs_web.dart | 0 .../utils/try_get_map_extension.dart | 0 lib/{src => matrix_api_lite}/values.dart | 0 pubspec.yaml | 24 - test/event_content_test.dart | 251 --- test/map_copy_extension_test.dart | 59 - test/matrix_api_test.dart | 1934 ----------------- test/try_get_map_extension_test.dart | 52 - 74 files changed, 3072 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml delete mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/ISSUE_TEMPLATE/epic.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature.yml delete mode 100644 .github/ISSUE_TEMPLATE/improvement.yml delete mode 100644 .github/workflows/general.yml delete mode 100644 .github/workflows/issue-triage.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/versions.env delete mode 100644 .gitignore delete mode 100644 .gitlab-ci.yml delete mode 100644 CHANGELOG.md delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 analysis_options.yaml delete mode 100644 example/matrix_api_lite_example.dart rename lib/{src => matrix_api_lite}/generated/api.dart (100%) rename lib/{src => matrix_api_lite}/generated/fixed_model.dart (100%) rename lib/{src => matrix_api_lite}/generated/internal.dart (100%) rename lib/{src => matrix_api_lite}/generated/model.dart (100%) rename lib/{src => matrix_api_lite}/generated/model.g.dart (100%) rename lib/{src => matrix_api_lite}/matrix_api.dart (100%) rename lib/{src => matrix_api_lite}/model/algorithm_types.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_data.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_identifier.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_password.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_phone_identifier.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_recaptcha.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_third_party_identifier.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_three_pid_creds.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_token.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_types.dart (100%) rename lib/{src => matrix_api_lite}/model/auth/authentication_user_identifier.dart (100%) rename lib/{src => matrix_api_lite}/model/basic_event.dart (100%) rename lib/{src => matrix_api_lite}/model/basic_event_with_sender.dart (100%) rename lib/{src => matrix_api_lite}/model/basic_room_event.dart (100%) rename lib/{src => matrix_api_lite}/model/children_state.dart (100%) rename lib/{src => matrix_api_lite}/model/event_types.dart (100%) rename lib/{src => matrix_api_lite}/model/events/forwarded_room_key_content.dart (100%) rename lib/{src => matrix_api_lite}/model/events/image_pack_content.dart (100%) rename lib/{src => matrix_api_lite}/model/events/olm_plaintext_payload.dart (100%) rename lib/{src => matrix_api_lite}/model/events/room_encrypted_content.dart (100%) rename lib/{src => matrix_api_lite}/model/events/room_encryption_content.dart (100%) rename lib/{src => matrix_api_lite}/model/events/room_key_content.dart (100%) rename lib/{src => matrix_api_lite}/model/events/room_key_request_content.dart (100%) rename lib/{src => matrix_api_lite}/model/events/secret_storage_default_key_content.dart (100%) rename lib/{src => matrix_api_lite}/model/events/secret_storage_key_content.dart (100%) rename lib/{src => matrix_api_lite}/model/events/tombstone_content.dart (100%) rename lib/{src => matrix_api_lite}/model/matrix_connection_exception.dart (100%) rename lib/{src => matrix_api_lite}/model/matrix_event.dart (100%) rename lib/{src => matrix_api_lite}/model/matrix_exception.dart (100%) rename lib/{src => matrix_api_lite}/model/matrix_keys.dart (100%) rename lib/{src => matrix_api_lite}/model/message_types.dart (100%) rename lib/{src => matrix_api_lite}/model/presence.dart (100%) rename lib/{src => matrix_api_lite}/model/presence_content.dart (100%) rename lib/{src => matrix_api_lite}/model/room_creation_types.dart (100%) rename lib/{src => matrix_api_lite}/model/room_keys_keys.dart (100%) rename lib/{src => matrix_api_lite}/model/room_summary.dart (100%) rename lib/{src => matrix_api_lite}/model/room_types.dart (100%) rename lib/{src => matrix_api_lite}/model/stripped_state_event.dart (100%) rename lib/{src => matrix_api_lite}/model/sync_update.dart (100%) rename lib/{src => matrix_api_lite}/utils/filter_map_extension.dart (100%) rename lib/{src => matrix_api_lite}/utils/logs.dart (100%) rename lib/{src => matrix_api_lite}/utils/map_copy_extension.dart (100%) rename lib/{src => matrix_api_lite}/utils/print_logs_native.dart (100%) rename lib/{src => matrix_api_lite}/utils/print_logs_web.dart (100%) rename lib/{src => matrix_api_lite}/utils/try_get_map_extension.dart (100%) rename lib/{src => matrix_api_lite}/values.dart (100%) delete mode 100644 pubspec.yaml delete mode 100644 test/event_content_test.dart delete mode 100644 test/map_copy_extension_test.dart delete mode 100644 test/matrix_api_test.dart delete mode 100644 test/try_get_map_extension_test.dart diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml deleted file mode 100644 index f029de76..00000000 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: 🐛 Bug Report -description: Report a bug to the product team -labels: ["bug"] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out this bug report! This will help us to improve the product :) - - type: checkboxes - attributes: - label: Checklist - description: Please search to see if an issue already exists for the bug you encountered. - options: - - label: I could not find a solution in the documentation, the existing issues or discussions. - required: true - - label: I already asked for help in the chat - - type: dropdown - attributes: - label: In which Project did the bug appear? - multiple: true - options: - - Famedly App - - Pharmacy Portal - - Flutter Admin Interface - - Other - - type: input - attributes: - label: If you selected \"Other\" as Project, please enter in which project the bug occurred. - - type: dropdown - attributes: - label: On which platform did the bug appear? - multiple: true - options: - - Android - - iOS - - Chrome - - Safari - - Firefox - - Edge - validations: - required: true - - type: input - attributes: - label: Matrix API Version - description: Which version of the Matrix Api (this Repo) are you using? - - type: textarea - attributes: - label: Describe the problem caused by this bug - description: | - A clear and concise description of the problem you have and what the bug is. - validations: - required: true - - type: textarea - attributes: - label: Steps To Reproduce - description: Steps to reproduce the behavior. - placeholder: | - 1. In this step... - 1. With this device... - 1. Run '...' - 1. See error... - validations: - required: false - - type: textarea - attributes: - label: Screenshots or Logs - description: If applicable, add screenshots or Logs to help explain your problem. - - type: textarea - attributes: - label: Security related - description: If there is something related to security, please add it here diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 3ba13e0c..00000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1 +0,0 @@ -blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/epic.yml b/.github/ISSUE_TEMPLATE/epic.yml deleted file mode 100644 index 83de96b5..00000000 --- a/.github/ISSUE_TEMPLATE/epic.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: 🥸 [Product only] Create epic -description: "Creates a new epic which is used to build the Famedly Roadmap" -labels: ["epic"] -body: - - type: markdown - attributes: - value: | - This should be filled out by product. - - type: textarea - id: summary - attributes: - label: summary - description: Please write a summary - validations: - required: true - - type: textarea - id: intended-outcome - attributes: - label: Intended Outcome - description: What is the outcome for the user? - validations: - required: true - - type: textarea - id: technical-solution - attributes: - label: How will it work? - description: Please write down, how it will work - - type: textarea - id: additional - attributes: - label: Additional Context - description: Please add any other infos that could be useful. diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml deleted file mode 100644 index 51f47a89..00000000 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: 🛠️ Feature -description: "Create an new issue for a new Feature in Famedly" -labels: ["feature"] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out this feature request - - type: checkboxes - id: preflight - attributes: - label: Preflight Checklist - options: - - label: - I could not find a solution in the existing issues, docs, nor discussions - required: true - - type: textarea - id: problem - attributes: - label: Describe your problem - description: Please describe your problem this new feature is supposed to solve. - placeholder: Describe the problem you have - validations: - required: true - - type: textarea - id: solution - attributes: - label: Describe your ideal solution - description: Which solution do you propose? - placeholder: As a [type of user], I want [some goal] so that [some reason]. - validations: - required: true - - type: input - id: version - attributes: - label: Version - description: Which version of the Famedly are you using. - - type: textarea - id: security - attributes: - label: Security requirements - description: Plese add more information in terms of security requirements. - - type: textarea - id: additional - attributes: - label: Additional Context - description: Please add any other infos that could be useful. diff --git a/.github/ISSUE_TEMPLATE/improvement.yml b/.github/ISSUE_TEMPLATE/improvement.yml deleted file mode 100644 index a9964478..00000000 --- a/.github/ISSUE_TEMPLATE/improvement.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: 🛠️ Improvement -description: "Create an new issue for an improvment in Famedly" -labels: ["improvement"] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out this improvement request - - type: checkboxes - id: preflight - attributes: - label: Preflight Checklist - options: - - label: - I could not find a solution in the existing issues, docs, nor discussions - required: true - - type: textarea - id: problem - attributes: - label: Describe your problem - description: Please describe your problem this improvement is supposed to solve. - placeholder: Describe the problem you have - validations: - required: true - - type: textarea - id: solution - attributes: - label: Describe your ideal solution - description: Which solution do you propose? - placeholder: As a [type of user], I want [some goal] so that [some reason]. - validations: - required: true - - type: input - id: version - attributes: - label: Version - description: Which version of the Famedly are you using. - - type: textarea - id: security - attributes: - label: Security requirements - description: Plese add more information in terms of security requirements. - - type: textarea - id: additional - attributes: - label: Additional Context - description: Please add any other infos that could be useful. diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml deleted file mode 100644 index 284e4236..00000000 --- a/.github/workflows/general.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: General CI - -on: - push: - branches: - - main - pull_request: - merge_group: - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - -jobs: - dart: - permissions: - contents: read - uses: famedly/frontend-ci-templates/.github/workflows/dart.yml@main - with: - env_file: ".github/workflows/versions.env" - - general: - permissions: - contents: read - uses: famedly/frontend-ci-templates/.github/workflows/general.yml@main diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml deleted file mode 100644 index 92a7abd1..00000000 --- a/.github/workflows/issue-triage.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Add issues to Product Management Project. - -on: - issues: - types: - - opened - -jobs: - add-to-project: - name: Add issue to project - runs-on: ubuntu-latest - steps: - - uses: actions/add-to-project@v0.5.0 - with: - # You can target a repository in a different organization - # to the issue - project-url: https://github.com/orgs/famedly/projects/4 - github-token: ${{ secrets.ADD_ISSUE_TO_PROJECT_PAT }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index d0401d8f..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Publish CI - -on: - push: - tags: - - v[0-9]+.[0-9]+.[0-9]+ - -jobs: - publish: - permissions: - contents: read - id-token: write - uses: famedly/frontend-ci-templates/.github/workflows/publish-pub.yml@main diff --git a/.github/workflows/versions.env b/.github/workflows/versions.env deleted file mode 100644 index 66280f74..00000000 --- a/.github/workflows/versions.env +++ /dev/null @@ -1,2 +0,0 @@ -flutter_version=3.13.6 -dart_version=3.1.3 diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 40dcabc2..00000000 --- a/.gitignore +++ /dev/null @@ -1,80 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.sw* -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -native/ -test/.test_coverage.dart -coverage/ -coverage_badge.svg - -# codegen related -*.bak -*.bakmacoscompat - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# Visual Studio Code related -.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -build/ -pubspec.lock - -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 93385c28..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,38 +0,0 @@ -include: - project: "famedly/company/frontend/ci-templates" - file: "all.yml" - -test: - stage: test - image: dart - script: - - dart pub get - - dart pub run test - -dry-run: - stage: deploy - image: dart - script: - - rm -rf ./docs - - dart pub get - - dart pub publish --dry-run - -pub-dev: - stage: deploy - image: dart - dependencies: [dry-run] - script: - - rm -rf ./docs - - | - if [ -z "${PUB_DEV_CREDENTIALS}" ]; then - echo "Missing PUB_DEV_CREDENTIALS environment variable" - exit 1 - fi - - mkdir -p ~/.config/dart/ - cp "${PUB_DEV_CREDENTIALS}" ~/.config/dart/pub-credentials.json - - - dart pub get - - dart pub publish --force - rules: - - if: $CI_COMMIT_TAG diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 11dfec70..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,242 +0,0 @@ -## [1.7.3] - 9th Jan 2023 -Mark package as discontinued. - -## [1.7.2] - 4th Oct 2023 - -- chore: add general and publish ci (td) -- chore: Add adjusted issue templates from product-management (Malin Errenst) -- chore: make dependencies compatible with dart 3 (Nicolas Werner) -- chore: add github action (Niklas Zender) - -## [1.7.1] - 22nd Jun 2023 - -- fix: Fixed fake_matrix_api.dart signedOneTimeKeys upload (Malin Errenst) -- fix: Fix type cast to fix test in matrix-fhir-dart-sdk (Malin Errenst) - -## [1.7.0] - 12th Jun 2023 - -Breaking Change: -Refactoring from Map to Map makes some -type casts neccessary - -- chore: add qr releated eventTypes (td) -- refactor: Get rid of dynamic lists (Krille) -- chore: bump version (Malin Errenst) -- docs: Add regenerate code instructions to readme (Krille) -- chore: Remove tags for CI test stage (Malin Errenst) -- refactor: Changed Map to Map (Malin Errenst) -- chore: generated folder from recent dart_openapi_codegen (Malin Errenst) -- chore: sort imports (Nicolas Werner) -- ci: Use the ci template (Nicolas Werner) - -## [1.6.1] - 17th Apr 2023 - -Fixes a small issue in the last release, where some enhanced enums were not -updated and as such missing a few members. - -- fix: Update the generated enum files - -## [1.6.0] - 17th Apr 2023 - -This release updates to version 1.6 of the Matrix specification. Users might -need to update their read receipt calls to the API changes. - -- feat: Upgrade to spec 1.6 - -## [1.1.10] - 27th Jan 2023 - -- chore: Update enhanced_enum to 0.2.4 - -## [1.1.9] - 7th Nov 2022 - -- feat: Allow converting of stacktraces in logs - -## [1.1.8] - 29th Aug 2022 - -- fix: Edge case where MatrixException.error differs from errcode -- chore: add pushrules to the event types - -## [1.1.7] - 29th Aug 2022 - -- fix: Parsing of MatrixException parameters - -## [1.1.6] - 26th Aug 2022 - -- fix: Fixed missing .pub-cache folder creation in .gitlab-ci.yml - -## [1.1.5] - 25th Aug 2022 - -- fix: Fixed dysfunctional key-verification (Emoji+manual) - -## [1.1.4] - 25th Aug 2022 - -- Revert "fix: Secret storage keys are used as account data but are not uri encoded" -- chore: disable dynamic calls (Nicolas Werner) -- chore: export filter map extension (Nicolas Werner) -- chore: strict casts (Nicolas Werner) -- chore: strict inference (Nicolas Werner) -- chore: strict raw types (Nicolas Werner) -- chore: upgrade from pedantic to lints (Nicolas Werner) - -## [1.1.3] - 2nd Aug 2022 - -- fix: Secret storage keys are used as account data but are not uri encoded -- chore: export filter map extension - -## [1.1.2] - 2nd Aug 2022 - -- feat: Add a flag to disable colors in logs - -## 1.1.1 - -- fix: wrong type for children_state in spaces hierarchy API -- fix: Missing trailing slash on pushrules endpoint -- tests: added tests for spaces hierarchy - -## 1.1.0 - -- fix: wrong types in spaces hierarchy API -- fix: Add missing versions to fake matrix api -- feat: Authenticate media downloads - -## 1.0.0 - -This release should be compatible with version 1.2 of the Matrix specification. - -- feat: Migrate to Matrix v1.2 spec -- feat: Add GroupCallPrefix/GroupCallMemberPrefix to EventTypes. - -## 0.5.3 - -- chore: Add missing matrix error types as per spec -- feat: add additionalProperties in PusherData -- feat: deletePusher - -## 0.5.2 - -- feat: Colored logs on native and web -- chore: Make some tryGet errors verbose and display line - -## 0.5.1 - -- feat: Add constructors to SyncUpdate classes - -## 0.5.0 - -- fix: threepidCreds should be threepid_creds and an object - -## 0.4.4 - -- chore: workaround for invalid getTurnServer responses from synapse - -## 0.4.3 - -- fix: Make type in AuthenticationData nullable -- refactor: remove uploadKeySignatures (use uploadCrossSigningSignatures) - -## 0.4.2 - -- feat: Add more call event for improve voip. - -## 0.4.1 - -- fix: change tryGet default loglevel to Optional - -## 0.4.0 - -- refactor: Migrate to null safety -- refactor: Use openAPI code generation to create most of the methods -- refactor: remove timeouts in matrix_api_lite - -## 0.3.5 - -- feat: Add image pack event content models - -## 0.3.3 - -- fix: Log filter in wrong direction - -## 0.3.2 - -- fix: Logs should only printed if loglevel is high enough - -## 0.3.1 - -- change: Remove logger package - -## 0.3.0 - -- feat: operation names from OpenAPI spec - -## 0.2.6 - -- fix: Missing RoomCreationTypes - -## 0.2.5 - -- fix: Request aliases - -## 0.2.3 - -- feat: Add room and event types for spaces - -## 0.2.2 - -- chore: upgrade logger to 1.0.0 -- refactor: upgrade to http 0.13 - -## 0.2.1 - -- fix: Update dependency mime - -## 0.2.0 - -- refactor: login method AuthenticationIdentifier - -This is a breaking change for the login method to use the correct format. -It makes it possible to login with email or phone. -Also this does some housekeeping stuff while -upgrading to pedantic 1.11.0 which doesnt -allow curly braces in Strings where not needed -anymore. - -## 0.1.9 - -- feat: Add support for fallback keys - -## 0.1.8 - -- fix: Wrong parameters use - -## 0.1.7 - -- change: Less noisy one-line logs - -## 0.1.6 - -- fix: well-known in fake_matrix_api - -## 0.1.5 - -- Add m.dummy event -- fix: Deep-copy arrays correctly - -## 0.1.4 - -- Fix creating shallow copies all the time - -## 0.1.3 - -- Set Content-Length on upload - -## 0.1.2 - -- Add more encryption and decryption content parsing - -## 0.1.1 - -- Add RoomEncryptedContent and RoomEncryptionContent - -## 0.1.0 - -- Initial version diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index bdbe67d9..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,37 +0,0 @@ -# Contributing code to Matrix API Lite - -Everyone is welcome to contribute code to Matrix API Lite, provided that they are willing to license their contributions under the same license as the project itself. -Please follow these rules when contributing code to Matrix API Lite: - -## Merge Requests: -- Never ever just push something directly to the main branch! -- Create a new branch or fork this project and send a Merge Request. -- Only Merge Requests with a working CI can be merged. -- Only Merge Requests with at least one code reviewer can be merged. -- Merge Requests may be refused if they don't follow the rules below. -- A new Merge Request SHOULD never decrease the test coverage. - -## Branches -### Naming - -Branches should get named by this pattern: `[Author]/[Description]`. - -## Commit Messages - -Please use [conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0-beta.2/). - -## File structure: -- Every file must be named by the class and must be capitalized in the beginning. -- Directories need to be lowercase. - -## Code style: -Please use code formatting. You can use VSCode or Android Studio. On other editors you need to run: -``` -flutter format lib/**/*/*.dart -``` - -## Code quality: -- Don't repeat yourself! Use local variables, functions, classes. -- Write tests for new classes, functions and widgets. -- Keep it simple stupid: https://en.wikipedia.org/wiki/KISS_principle -- Describe all of your classes, methods and attributes using **dartdoc** comments. Read this for more information: https://dart.dev/guides/language/effective-dart/documentation \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 2c086bbb..00000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (C) 2021 Famedly GmbH - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index 3fa7bdb8..00000000 --- a/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Deprecation Notice: - -This package will soon be merged with the [Matrix Dart SDK](https://pub.dev/packages/matrix) and from there be available as a library, not a stand alone package anymore. We hope that this will save us some overhead when maintaining the code. If you rely on this package as stand alone and importing the whole Matrix Dart SDK just to use this library is not an option for you, please open an issue here: https://github.com/famedly/dart_matrix_api_lite/issues - -# Matrix API Lite - -This package is a dead simple data model over the client-server specification of https://matrix.org and is mostly used as a base for a more complete Matrix SDK. -It doesn't contain any logic and just provides methods for all API endpoints and json parser for all objects. It is intended to be as close to the specificaton -as possible so we get a 1:1 relationship with the API. More complex logic like a sync loop or a data model for rooms should be implemented in a more complete -Matrix SDK. - -## Usage - -A simple usage example: - -```dart -import 'package:matrix_api_lite/src/matrix_api.dart'; - -void main() async { - final api = MatrixApi(homeserver: Uri.parse('https://matrix.org')); - final capabilities = await api.requestServerCapabilities(); - print(capabilities.toJson()); -} - -``` - -## Generated code - -The files in `lib/src/generated` are generated by [dart_openapi_codegen](https://gitlab.com/famedly/company/frontend/dart_openapi_codegen/) -from [matrix-spec](https://github.com/matrix-org/matrix-spec/). - -To regenerate the code, follow these steps: - -1. Clone both repositories next to each other - 1.1 `git clone git@github.com:famedly/dart_openapi_codegen.git` - 1.2 `git clone git@github.com:famedly/dart_matrix_api_lite.git` -2. Execute the script in the dart_openapi_codegen directory: -```sh -cd dart_openapi_codegen -./scripts/matrix.sh ../dart_matrix_api_lite/lib/src/generated -cd .. -``` -3. Run the build_runner in the matrix_api_lite directory: -```sh -cd dart_matrix_api_lite -dart pub get -dart run build_runner build -``` -4. Check lints and tests and create a merge request \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml deleted file mode 100644 index 58ead17c..00000000 --- a/analysis_options.yaml +++ /dev/null @@ -1,21 +0,0 @@ -include: package:lints/recommended.yaml - -linter: - rules: - camel_case_types: true - avoid_print: true - constant_identifier_names: false - prefer_final_locals: true - prefer_final_in_for_each: true - avoid_dynamic_calls: true - -analyzer: - language: - strict-casts: true - strict-inference: true - strict-raw-types: true - errors: - todo: ignore - exclude: - - example/matrix_api_lite_example.dart - - lib/src/generated/**.dart diff --git a/example/matrix_api_lite_example.dart b/example/matrix_api_lite_example.dart deleted file mode 100644 index 70876234..00000000 --- a/example/matrix_api_lite_example.dart +++ /dev/null @@ -1,8 +0,0 @@ -// @dart=2.9 -import 'package:matrix_api_lite/src/matrix_api.dart'; - -void main() async { - final api = MatrixApi(homeserver: Uri.parse('https://matrix.org')); - final capabilities = await api.requestServerCapabilities(); - print(capabilities.toJson()); -} diff --git a/lib/src/generated/api.dart b/lib/matrix_api_lite/generated/api.dart similarity index 100% rename from lib/src/generated/api.dart rename to lib/matrix_api_lite/generated/api.dart diff --git a/lib/src/generated/fixed_model.dart b/lib/matrix_api_lite/generated/fixed_model.dart similarity index 100% rename from lib/src/generated/fixed_model.dart rename to lib/matrix_api_lite/generated/fixed_model.dart diff --git a/lib/src/generated/internal.dart b/lib/matrix_api_lite/generated/internal.dart similarity index 100% rename from lib/src/generated/internal.dart rename to lib/matrix_api_lite/generated/internal.dart diff --git a/lib/src/generated/model.dart b/lib/matrix_api_lite/generated/model.dart similarity index 100% rename from lib/src/generated/model.dart rename to lib/matrix_api_lite/generated/model.dart diff --git a/lib/src/generated/model.g.dart b/lib/matrix_api_lite/generated/model.g.dart similarity index 100% rename from lib/src/generated/model.g.dart rename to lib/matrix_api_lite/generated/model.g.dart diff --git a/lib/src/matrix_api.dart b/lib/matrix_api_lite/matrix_api.dart similarity index 100% rename from lib/src/matrix_api.dart rename to lib/matrix_api_lite/matrix_api.dart diff --git a/lib/src/model/algorithm_types.dart b/lib/matrix_api_lite/model/algorithm_types.dart similarity index 100% rename from lib/src/model/algorithm_types.dart rename to lib/matrix_api_lite/model/algorithm_types.dart diff --git a/lib/src/model/auth/authentication_data.dart b/lib/matrix_api_lite/model/auth/authentication_data.dart similarity index 100% rename from lib/src/model/auth/authentication_data.dart rename to lib/matrix_api_lite/model/auth/authentication_data.dart diff --git a/lib/src/model/auth/authentication_identifier.dart b/lib/matrix_api_lite/model/auth/authentication_identifier.dart similarity index 100% rename from lib/src/model/auth/authentication_identifier.dart rename to lib/matrix_api_lite/model/auth/authentication_identifier.dart diff --git a/lib/src/model/auth/authentication_password.dart b/lib/matrix_api_lite/model/auth/authentication_password.dart similarity index 100% rename from lib/src/model/auth/authentication_password.dart rename to lib/matrix_api_lite/model/auth/authentication_password.dart diff --git a/lib/src/model/auth/authentication_phone_identifier.dart b/lib/matrix_api_lite/model/auth/authentication_phone_identifier.dart similarity index 100% rename from lib/src/model/auth/authentication_phone_identifier.dart rename to lib/matrix_api_lite/model/auth/authentication_phone_identifier.dart diff --git a/lib/src/model/auth/authentication_recaptcha.dart b/lib/matrix_api_lite/model/auth/authentication_recaptcha.dart similarity index 100% rename from lib/src/model/auth/authentication_recaptcha.dart rename to lib/matrix_api_lite/model/auth/authentication_recaptcha.dart diff --git a/lib/src/model/auth/authentication_third_party_identifier.dart b/lib/matrix_api_lite/model/auth/authentication_third_party_identifier.dart similarity index 100% rename from lib/src/model/auth/authentication_third_party_identifier.dart rename to lib/matrix_api_lite/model/auth/authentication_third_party_identifier.dart diff --git a/lib/src/model/auth/authentication_three_pid_creds.dart b/lib/matrix_api_lite/model/auth/authentication_three_pid_creds.dart similarity index 100% rename from lib/src/model/auth/authentication_three_pid_creds.dart rename to lib/matrix_api_lite/model/auth/authentication_three_pid_creds.dart diff --git a/lib/src/model/auth/authentication_token.dart b/lib/matrix_api_lite/model/auth/authentication_token.dart similarity index 100% rename from lib/src/model/auth/authentication_token.dart rename to lib/matrix_api_lite/model/auth/authentication_token.dart diff --git a/lib/src/model/auth/authentication_types.dart b/lib/matrix_api_lite/model/auth/authentication_types.dart similarity index 100% rename from lib/src/model/auth/authentication_types.dart rename to lib/matrix_api_lite/model/auth/authentication_types.dart diff --git a/lib/src/model/auth/authentication_user_identifier.dart b/lib/matrix_api_lite/model/auth/authentication_user_identifier.dart similarity index 100% rename from lib/src/model/auth/authentication_user_identifier.dart rename to lib/matrix_api_lite/model/auth/authentication_user_identifier.dart diff --git a/lib/src/model/basic_event.dart b/lib/matrix_api_lite/model/basic_event.dart similarity index 100% rename from lib/src/model/basic_event.dart rename to lib/matrix_api_lite/model/basic_event.dart diff --git a/lib/src/model/basic_event_with_sender.dart b/lib/matrix_api_lite/model/basic_event_with_sender.dart similarity index 100% rename from lib/src/model/basic_event_with_sender.dart rename to lib/matrix_api_lite/model/basic_event_with_sender.dart diff --git a/lib/src/model/basic_room_event.dart b/lib/matrix_api_lite/model/basic_room_event.dart similarity index 100% rename from lib/src/model/basic_room_event.dart rename to lib/matrix_api_lite/model/basic_room_event.dart diff --git a/lib/src/model/children_state.dart b/lib/matrix_api_lite/model/children_state.dart similarity index 100% rename from lib/src/model/children_state.dart rename to lib/matrix_api_lite/model/children_state.dart diff --git a/lib/src/model/event_types.dart b/lib/matrix_api_lite/model/event_types.dart similarity index 100% rename from lib/src/model/event_types.dart rename to lib/matrix_api_lite/model/event_types.dart diff --git a/lib/src/model/events/forwarded_room_key_content.dart b/lib/matrix_api_lite/model/events/forwarded_room_key_content.dart similarity index 100% rename from lib/src/model/events/forwarded_room_key_content.dart rename to lib/matrix_api_lite/model/events/forwarded_room_key_content.dart diff --git a/lib/src/model/events/image_pack_content.dart b/lib/matrix_api_lite/model/events/image_pack_content.dart similarity index 100% rename from lib/src/model/events/image_pack_content.dart rename to lib/matrix_api_lite/model/events/image_pack_content.dart diff --git a/lib/src/model/events/olm_plaintext_payload.dart b/lib/matrix_api_lite/model/events/olm_plaintext_payload.dart similarity index 100% rename from lib/src/model/events/olm_plaintext_payload.dart rename to lib/matrix_api_lite/model/events/olm_plaintext_payload.dart diff --git a/lib/src/model/events/room_encrypted_content.dart b/lib/matrix_api_lite/model/events/room_encrypted_content.dart similarity index 100% rename from lib/src/model/events/room_encrypted_content.dart rename to lib/matrix_api_lite/model/events/room_encrypted_content.dart diff --git a/lib/src/model/events/room_encryption_content.dart b/lib/matrix_api_lite/model/events/room_encryption_content.dart similarity index 100% rename from lib/src/model/events/room_encryption_content.dart rename to lib/matrix_api_lite/model/events/room_encryption_content.dart diff --git a/lib/src/model/events/room_key_content.dart b/lib/matrix_api_lite/model/events/room_key_content.dart similarity index 100% rename from lib/src/model/events/room_key_content.dart rename to lib/matrix_api_lite/model/events/room_key_content.dart diff --git a/lib/src/model/events/room_key_request_content.dart b/lib/matrix_api_lite/model/events/room_key_request_content.dart similarity index 100% rename from lib/src/model/events/room_key_request_content.dart rename to lib/matrix_api_lite/model/events/room_key_request_content.dart diff --git a/lib/src/model/events/secret_storage_default_key_content.dart b/lib/matrix_api_lite/model/events/secret_storage_default_key_content.dart similarity index 100% rename from lib/src/model/events/secret_storage_default_key_content.dart rename to lib/matrix_api_lite/model/events/secret_storage_default_key_content.dart diff --git a/lib/src/model/events/secret_storage_key_content.dart b/lib/matrix_api_lite/model/events/secret_storage_key_content.dart similarity index 100% rename from lib/src/model/events/secret_storage_key_content.dart rename to lib/matrix_api_lite/model/events/secret_storage_key_content.dart diff --git a/lib/src/model/events/tombstone_content.dart b/lib/matrix_api_lite/model/events/tombstone_content.dart similarity index 100% rename from lib/src/model/events/tombstone_content.dart rename to lib/matrix_api_lite/model/events/tombstone_content.dart diff --git a/lib/src/model/matrix_connection_exception.dart b/lib/matrix_api_lite/model/matrix_connection_exception.dart similarity index 100% rename from lib/src/model/matrix_connection_exception.dart rename to lib/matrix_api_lite/model/matrix_connection_exception.dart diff --git a/lib/src/model/matrix_event.dart b/lib/matrix_api_lite/model/matrix_event.dart similarity index 100% rename from lib/src/model/matrix_event.dart rename to lib/matrix_api_lite/model/matrix_event.dart diff --git a/lib/src/model/matrix_exception.dart b/lib/matrix_api_lite/model/matrix_exception.dart similarity index 100% rename from lib/src/model/matrix_exception.dart rename to lib/matrix_api_lite/model/matrix_exception.dart diff --git a/lib/src/model/matrix_keys.dart b/lib/matrix_api_lite/model/matrix_keys.dart similarity index 100% rename from lib/src/model/matrix_keys.dart rename to lib/matrix_api_lite/model/matrix_keys.dart diff --git a/lib/src/model/message_types.dart b/lib/matrix_api_lite/model/message_types.dart similarity index 100% rename from lib/src/model/message_types.dart rename to lib/matrix_api_lite/model/message_types.dart diff --git a/lib/src/model/presence.dart b/lib/matrix_api_lite/model/presence.dart similarity index 100% rename from lib/src/model/presence.dart rename to lib/matrix_api_lite/model/presence.dart diff --git a/lib/src/model/presence_content.dart b/lib/matrix_api_lite/model/presence_content.dart similarity index 100% rename from lib/src/model/presence_content.dart rename to lib/matrix_api_lite/model/presence_content.dart diff --git a/lib/src/model/room_creation_types.dart b/lib/matrix_api_lite/model/room_creation_types.dart similarity index 100% rename from lib/src/model/room_creation_types.dart rename to lib/matrix_api_lite/model/room_creation_types.dart diff --git a/lib/src/model/room_keys_keys.dart b/lib/matrix_api_lite/model/room_keys_keys.dart similarity index 100% rename from lib/src/model/room_keys_keys.dart rename to lib/matrix_api_lite/model/room_keys_keys.dart diff --git a/lib/src/model/room_summary.dart b/lib/matrix_api_lite/model/room_summary.dart similarity index 100% rename from lib/src/model/room_summary.dart rename to lib/matrix_api_lite/model/room_summary.dart diff --git a/lib/src/model/room_types.dart b/lib/matrix_api_lite/model/room_types.dart similarity index 100% rename from lib/src/model/room_types.dart rename to lib/matrix_api_lite/model/room_types.dart diff --git a/lib/src/model/stripped_state_event.dart b/lib/matrix_api_lite/model/stripped_state_event.dart similarity index 100% rename from lib/src/model/stripped_state_event.dart rename to lib/matrix_api_lite/model/stripped_state_event.dart diff --git a/lib/src/model/sync_update.dart b/lib/matrix_api_lite/model/sync_update.dart similarity index 100% rename from lib/src/model/sync_update.dart rename to lib/matrix_api_lite/model/sync_update.dart diff --git a/lib/src/utils/filter_map_extension.dart b/lib/matrix_api_lite/utils/filter_map_extension.dart similarity index 100% rename from lib/src/utils/filter_map_extension.dart rename to lib/matrix_api_lite/utils/filter_map_extension.dart diff --git a/lib/src/utils/logs.dart b/lib/matrix_api_lite/utils/logs.dart similarity index 100% rename from lib/src/utils/logs.dart rename to lib/matrix_api_lite/utils/logs.dart diff --git a/lib/src/utils/map_copy_extension.dart b/lib/matrix_api_lite/utils/map_copy_extension.dart similarity index 100% rename from lib/src/utils/map_copy_extension.dart rename to lib/matrix_api_lite/utils/map_copy_extension.dart diff --git a/lib/src/utils/print_logs_native.dart b/lib/matrix_api_lite/utils/print_logs_native.dart similarity index 100% rename from lib/src/utils/print_logs_native.dart rename to lib/matrix_api_lite/utils/print_logs_native.dart diff --git a/lib/src/utils/print_logs_web.dart b/lib/matrix_api_lite/utils/print_logs_web.dart similarity index 100% rename from lib/src/utils/print_logs_web.dart rename to lib/matrix_api_lite/utils/print_logs_web.dart diff --git a/lib/src/utils/try_get_map_extension.dart b/lib/matrix_api_lite/utils/try_get_map_extension.dart similarity index 100% rename from lib/src/utils/try_get_map_extension.dart rename to lib/matrix_api_lite/utils/try_get_map_extension.dart diff --git a/lib/src/values.dart b/lib/matrix_api_lite/values.dart similarity index 100% rename from lib/src/values.dart rename to lib/matrix_api_lite/values.dart diff --git a/pubspec.yaml b/pubspec.yaml deleted file mode 100644 index 6f80e07b..00000000 --- a/pubspec.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: matrix_api_lite -description: Dead simple data model for the matrix.org client-server API. -version: 1.7.3 -homepage: https://famedly.com -repository: https://github.com/famedly/dart_matrix_api_lite -issues: https://github.com/famedly/dart_matrix_api_lite/issues - -environment: - sdk: ">=2.17.0 <4.0.0" - -dependencies: - enhanced_enum: ^0.2.4 - http: ">=0.13.0 <2.0.0" - mime: ^1.0.0 - -dev_dependencies: - build_runner: ^2.1.8 - enhanced_enum_generator: ^0.2.4 - import_sorter: ^4.6.0 - lints: ^2.0.0 - test: ^1.14.4 -# dependency_overrides: # uncomment for local development -# matrix: -# path: "../matrix-dart-sdk" diff --git a/test/event_content_test.dart b/test/event_content_test.dart deleted file mode 100644 index 6b769ba0..00000000 --- a/test/event_content_test.dart +++ /dev/null @@ -1,251 +0,0 @@ -/* MIT License -* -* Copyright (C) 2019, 2020, 2021 Famedly GmbH -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all -* copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -import 'dart:convert'; - -import 'package:test/test.dart'; - -import 'package:matrix_api_lite/matrix_api_lite.dart'; - -void main() { - group('Event Content tests', () { - test('Room Encryption Content', () { - Map? json = { - 'content': { - 'algorithm': 'm.megolm.v1.aes-sha2', - 'rotation_period_ms': 604800000, - 'rotation_period_msgs': 100 - }, - 'event_id': '\$143273582443PhrSn:example.org', - 'origin_server_ts': 1432735824653, - 'room_id': '!jEsUZKDJdhlrceRyVU:example.org', - 'sender': '@example:example.org', - 'state_key': '', - 'type': 'm.room.encryption', - 'unsigned': {'age': 1234} - }; - json = jsonDecode(jsonEncode(json)) as Map?; - expect(MatrixEvent.fromJson(json!).parsedRoomEncryptionContent.toJson(), - json['content']); - }); - test('Room Encrypted Content', () { - Map? json = { - 'content': { - 'algorithm': 'm.megolm.v1.aes-sha2', - 'ciphertext': 'AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...', - 'device_id': 'RJYKSTBOIE', - 'sender_key': 'IlRMeOPX2e0MurIyfWEucYBRVOEEUMrOHqn/8mLqMjA', - 'session_id': 'X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ' - }, - 'event_id': '\$143273582443PhrSn:example.org', - 'origin_server_ts': 1432735824653, - 'room_id': '!jEsUZKDJdhlrceRyVU:example.org', - 'sender': '@example:example.org', - 'type': 'm.room.encrypted', - 'unsigned': {'age': 1234} - }; - json = jsonDecode(jsonEncode(json)) as Map?; - expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(), - json['content']); - json = { - 'content': { - 'algorithm': 'm.olm.v1.curve25519-aes-sha2', - 'ciphertext': { - '7qZcfnBmbEGzxxaWfBjElJuvn7BZx+lSz/SvFrDF/z8': { - 'body': 'AwogGJJzMhf/S3GQFXAOrCZ3iKyGU5ZScVtjI0KypTYrW...', - 'type': 0 - } - }, - 'sender_key': 'Szl29ksW/L8yZGWAX+8dY1XyFi+i5wm+DRhTGkbMiwU' - }, - 'event_id': '\$143273582443PhrSn:example.org', - 'origin_server_ts': 1432735824653, - 'room_id': '!jEsUZKDJdhlrceRyVU:example.org', - 'sender': '@example:example.org', - 'type': 'm.room.encrypted', - 'unsigned': {'age': 1234} - }; - json = jsonDecode(jsonEncode(json)) as Map?; - expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(), - json['content']); - }); - test('Room Key Content', () { - Map? json = { - 'content': { - 'algorithm': 'm.megolm.v1.aes-sha2', - 'room_id': '!Cuyf34gef24t:localhost', - 'session_id': 'X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ', - 'session_key': 'AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8LlfJL7qNBEY...' - }, - 'type': 'm.room_key' - }; - json = jsonDecode(jsonEncode(json)) as Map?; - expect(BasicEvent.fromJson(json!).parsedRoomKeyContent.toJson(), - json['content']); - }); - test('Room Key Request Content', () { - Map? json = { - 'content': { - 'action': 'request_cancellation', - 'request_id': '1495474790150.19', - 'requesting_device_id': 'RJYKSTBOIE' - }, - 'type': 'm.room_key_request' - }; - json = jsonDecode(jsonEncode(json)) as Map?; - expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(), - json['content']); - json = { - 'content': { - 'action': 'request', - 'body': { - 'algorithm': 'm.megolm.v1.aes-sha2', - 'room_id': '!Cuyf34gef24t:localhost', - 'sender_key': 'RF3s+E7RkTQTGF2d8Deol0FkQvgII2aJDf3/Jp5mxVU', - 'session_id': 'X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ' - }, - 'request_id': '1495474790150.19', - 'requesting_device_id': 'RJYKSTBOIE' - }, - 'type': 'm.room_key_request' - }; - json = jsonDecode(jsonEncode(json)) as Map?; - expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(), - json['content']); - }); - test('Forwarded Room Key Content', () { - Map? json = { - 'content': { - 'algorithm': 'm.megolm.v1.aes-sha2', - 'forwarding_curve25519_key_chain': [ - 'hPQNcabIABgGnx3/ACv/jmMmiQHoeFfuLB17tzWp6Hw' - ], - 'room_id': '!Cuyf34gef24t:localhost', - 'sender_claimed_ed25519_key': - 'aj40p+aw64yPIdsxoog8jhPu9i7l7NcFRecuOQblE3Y', - 'sender_key': 'RF3s+E7RkTQTGF2d8Deol0FkQvgII2aJDf3/Jp5mxVU', - 'session_id': 'X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ', - 'session_key': 'AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8Llf...' - }, - 'type': 'm.forwarded_room_key' - }; - json = jsonDecode(jsonEncode(json)) as Map?; - expect(BasicEvent.fromJson(json!).parsedForwardedRoomKeyContent.toJson(), - json['content']); - }); - test('OLM Plaintext Payload', () { - Map? json = { - 'type': '', - 'content': { - 'msgtype': 'm.text', - 'body': 'Hello world', - }, - 'sender': '', - 'recipient': '', - 'recipient_keys': {'ed25519': ''}, - 'keys': {'ed25519': ''} - }; - json = jsonDecode(jsonEncode(json)) as Map?; - expect(OlmPlaintextPayload.fromJson(json!).toJson(), json); - }); - test('Image Pack Content', () { - // basic parse / unparse - var json = { - 'type': 'some type', - 'content': { - 'images': { - 'emote': { - 'url': 'mxc://example.org/beep', - 'usage': ['emoticon'], - 'org.custom': 'beep', - }, - 'sticker': { - 'url': 'mxc://example.org/boop', - 'usage': ['org.custom', 'sticker', 'org.other.custom'], - }, - }, - 'pack': { - 'display_name': 'Awesome Pack', - 'org.custom': 'boop', - }, - 'org.custom': 'blah', - }, - }; - json = jsonDecode(jsonEncode(json)) as Map; - expect(BasicEvent.fromJson(json).parsedImagePackContent.toJson(), - json['content']); - - // emoticons migration - json = { - 'type': 'some type', - 'content': { - 'emoticons': { - ':emote:': { - 'url': 'mxc://example.org/beep', - }, - }, - }, - }; - json = jsonDecode(jsonEncode(json)) as Map; - expect( - BasicEvent.fromJson(json) - .parsedImagePackContent - .images['emote'] - ?.toJson(), - { - 'url': 'mxc://example.org/beep', - }); - - json = { - 'type': 'some type', - 'content': { - 'short': { - ':emote:': 'mxc://example.org/beep', - }, - }, - }; - json = jsonDecode(jsonEncode(json)) as Map; - expect( - BasicEvent.fromJson(json) - .parsedImagePackContent - .images['emote'] - ?.toJson(), - { - 'url': 'mxc://example.org/beep', - }); - - // invalid url for image - json = { - 'type': 'some type', - 'content': { - 'images': { - 'emote': {}, - }, - }, - }; - json = jsonDecode(jsonEncode(json)) as Map; - expect(BasicEvent.fromJson(json).parsedImagePackContent.images['emote'], - null); - }); - }); -} diff --git a/test/map_copy_extension_test.dart b/test/map_copy_extension_test.dart deleted file mode 100644 index d20b61e8..00000000 --- a/test/map_copy_extension_test.dart +++ /dev/null @@ -1,59 +0,0 @@ -/* MIT License -* -* Copyright (C) 2019, 2020, 2021 Famedly GmbH -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all -* copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -import 'package:test/test.dart'; - -import 'package:matrix_api_lite/matrix_api_lite.dart'; - -void main() { - group('Map-copy-extension', () { - test('it should work', () { - final original = { - 'attr': 'fox', - 'child': { - 'attr': 'bunny', - 'list': [1, 2], - }, - }; - final copy = original.copy(); - (original['child'] as Map)['attr'] = 'raccoon'; - expect((copy['child'] as Map)['attr'], 'bunny'); - ((original['child'] as Map)['list'] as List).add(3); - expect((copy['child'] as Map)['list'], [1, 2]); - }); - test('should do arrays', () { - final original = { - 'arr': [ - [1, 2], - {'beep': 'boop'}, - ], - }; - final copy = original.copy(); - ((original['arr'] as List)[0] as List).add(3); - expect((copy['arr'] as List)[0], [1, 2]); - ((original['arr'] as List)[1] as Map)['beep'] = 'blargh'; - expect( - ((copy['arr'] as List)[1] as Map)['beep'], 'boop'); - }); - }); -} diff --git a/test/matrix_api_test.dart b/test/matrix_api_test.dart deleted file mode 100644 index 9b6943c0..00000000 --- a/test/matrix_api_test.dart +++ /dev/null @@ -1,1934 +0,0 @@ -/* MIT License -* -* Copyright (C) 2019, 2020, 2021 Famedly GmbH -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all -* copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -import 'dart:typed_data'; - -import 'package:test/test.dart'; - -import 'package:matrix_api_lite/fake_matrix_api.dart'; -import 'package:matrix_api_lite/matrix_api_lite.dart'; - -const emptyRequest = {}; - -void main() { - /// All Tests related to device keys - group('Matrix API', () { - test('Logger', () async { - Logs().level = Level.verbose; - Logs().v('Test log'); - Logs().d('Test log'); - Logs().w('Test log'); - Logs().e('Test log'); - Logs().wtf('Test log'); - Logs().v('Test log', Exception('There has been a verbose')); - Logs().d('Test log', Exception('Test')); - Logs().w('Test log', Exception('Very bad error')); - Logs().e('Test log', Exception('Test'), StackTrace.current); - Logs().wtf('Test log', Exception('Test'), StackTrace.current); - }); - Logs().level = Level.error; - final matrixApi = MatrixApi( - httpClient: FakeMatrixApi(), - ); - test('MatrixException test', () async { - final exception = MatrixException.fromJson({ - 'flows': [ - { - 'stages': ['example.type.foo'] - } - ], - 'params': { - 'example.type.baz': {'example_key': 'foobar'} - }, - 'session': 'xxxxxxyz', - 'completed': ['example.type.foo'] - }); - expect(exception.authenticationFlows!.first.stages.first, - 'example.type.foo'); - expect(exception.authenticationParams!['example.type.baz'], - {'example_key': 'foobar'}); - expect(exception.session, 'xxxxxxyz'); - expect(exception.completedAuthenticationFlows, ['example.type.foo']); - expect(exception.requireAdditionalAuthentication, true); - expect(exception.retryAfterMs, null); - expect(exception.error, MatrixError.M_FORBIDDEN); - expect(exception.errcode, 'M_FORBIDDEN'); - expect(exception.errorMessage, 'Require additional authentication'); - }); - test('triggerNotFoundError', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - bool error; - error = false; - try { - await matrixApi.request(RequestType.GET, '/fake/path'); - } catch (_) { - error = true; - } - expect(error, true); - error = false; - try { - await matrixApi.request(RequestType.POST, '/fake/path'); - } catch (_) { - error = true; - } - expect(error, true); - error = false; - try { - await matrixApi.request(RequestType.PUT, '/fake/path'); - } catch (_) { - error = true; - } - expect(error, true); - error = false; - try { - await matrixApi.request(RequestType.DELETE, '/fake/path'); - } catch (_) { - error = true; - } - expect(error, true); - error = false; - try { - await matrixApi.request(RequestType.GET, '/path/to/auth/error/'); - } catch (exception) { - expect(exception is MatrixException, true); - expect((exception as MatrixException).errcode, 'M_FORBIDDEN'); - expect(exception.error, MatrixError.M_FORBIDDEN); - expect(exception.errorMessage, 'Blabla'); - expect(exception.requireAdditionalAuthentication, false); - expect(exception.toString(), 'M_FORBIDDEN: Blabla'); - error = true; - } - expect(error, true); - matrixApi.homeserver = null; - }); - test('getSupportedVersions', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - final supportedVersions = await matrixApi.getVersions(); - expect(supportedVersions.versions.contains('r0.5.0'), true); - expect(supportedVersions.unstableFeatures!['m.lazy_load_members'], true); - expect(FakeMatrixApi.api['GET']!['/client/versions']!.call(emptyRequest), - supportedVersions.toJson()); - matrixApi.homeserver = null; - }); - test('getWellKnownInformation', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - final wellKnownInformation = await matrixApi.getWellknown(); - expect(wellKnownInformation.mHomeserver.baseUrl, - Uri.parse('https://fakeserver.notexisting')); - expect(wellKnownInformation.toJson(), { - 'm.homeserver': {'base_url': 'https://fakeserver.notexisting'}, - 'm.identity_server': { - 'base_url': 'https://identity.fakeserver.notexisting' - }, - 'org.example.custom.property': { - 'app_url': 'https://custom.app.fakeserver.notexisting' - } - }); - }); - test('getLoginTypes', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - final loginTypes = await matrixApi.getLoginFlows(); - expect(loginTypes?.first.type, 'm.login.password'); - expect(FakeMatrixApi.api['GET']!['/client/v3/login']!.call(emptyRequest), - {'flows': loginTypes?.map((x) => x.toJson()).toList()}); - matrixApi.homeserver = null; - }); - test('login', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - final loginResponse = await matrixApi.login( - LoginType.mLoginPassword, - identifier: AuthenticationUserIdentifier(user: 'username'), - ); - expect(FakeMatrixApi.api['POST']!['/client/v3/login']!.call(emptyRequest), - loginResponse.toJson()); - matrixApi.homeserver = null; - }); - test('logout', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.logout(); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('logoutAll', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.logoutAll(); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('register', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - final registerResponse = - await matrixApi.register(kind: AccountKind.guest, username: 'test'); - expect( - FakeMatrixApi.api['POST']!['/client/v3/register?kind=guest']! - .call(emptyRequest), - registerResponse.toJson()); - matrixApi.homeserver = null; - }); - test('requestTokenToRegisterEmail', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = await matrixApi.requestTokenToRegisterEmail( - 'alice@example.com', - '1234', - 1, - nextLink: 'https://example.com', - idServer: 'https://example.com', - idAccessToken: '1234', - ); - expect( - FakeMatrixApi.api['POST']!['/client/v3/register/email/requestToken']! - .call(emptyRequest), - response.toJson()); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestTokenToRegisterMSISDN', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = await matrixApi.requestTokenToRegisterMSISDN( - 'en', - '1234', - '1234', - 1, - nextLink: 'https://example.com', - idServer: 'https://example.com', - idAccessToken: '1234', - ); - expect( - FakeMatrixApi.api['POST']!['/client/v3/register/email/requestToken']! - .call(emptyRequest), - response.toJson()); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('changePassword', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.changePassword( - '1234', - auth: AuthenticationData.fromJson({ - 'type': 'example.type.foo', - 'session': 'xxxxx', - 'example_credential': 'verypoorsharedsecret' - }), - ); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestTokenToResetPasswordEmail', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.requestTokenToResetPasswordEmail( - 'alice@example.com', - '1234', - 1, - nextLink: 'https://example.com', - idServer: 'https://example.com', - idAccessToken: '1234', - ); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestTokenToResetPasswordMSISDN', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.requestTokenToResetPasswordMSISDN( - 'en', - '1234', - '1234', - 1, - nextLink: 'https://example.com', - idServer: 'https://example.com', - idAccessToken: '1234', - ); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('deactivateAccount', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = await matrixApi.deactivateAccount( - idServer: 'https://example.com', - auth: AuthenticationData.fromJson({ - 'type': 'example.type.foo', - 'session': 'xxxxx', - 'example_credential': 'verypoorsharedsecret' - }), - ); - expect(response, IdServerUnbindResult.success); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('usernameAvailable', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - final loginResponse = - await matrixApi.checkUsernameAvailability('testuser'); - expect(loginResponse, true); - matrixApi.homeserver = null; - }); - test('getThirdPartyIdentifiers', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = await matrixApi.getAccount3PIDs(); - expect( - FakeMatrixApi.api['GET']!['/client/v3/account/3pid']! - .call(emptyRequest), - {'threepids': response?.map((t) => t.toJson()).toList()}); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('addThirdPartyIdentifier', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.add3PID('1234', '1234', - auth: AuthenticationData.fromJson({'type': 'm.login.dummy'})); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('bindThirdPartyIdentifier', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.bind3PID( - '1234', - '1234', - 'https://example.com', - '1234', - ); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('deleteThirdPartyIdentifier', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = await matrixApi.delete3pidFromAccount( - 'alice@example.com', - ThirdPartyIdentifierMedium.email, - idServer: 'https://example.com', - ); - expect(response, IdServerUnbindResult.success); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('unbindThirdPartyIdentifier', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = await matrixApi.unbind3pidFromAccount( - 'alice@example.com', - ThirdPartyIdentifierMedium.email, - idServer: 'https://example.com', - ); - expect(response, IdServerUnbindResult.success); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestTokenTo3PIDEmail', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.requestTokenTo3PIDEmail( - 'alice@example.com', - '1234', - 1, - nextLink: 'https://example.com', - idServer: 'https://example.com', - idAccessToken: '1234', - ); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestTokenTo3PIDMSISDN', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.requestTokenTo3PIDMSISDN( - 'en', - '1234', - '1234', - 1, - nextLink: 'https://example.com', - idServer: 'https://example.com', - idAccessToken: '1234', - ); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestTokenTo3PIDMSISDN', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = await matrixApi.getTokenOwner(); - expect(response.userId, 'alice@example.com'); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('getCapabilities', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = await matrixApi.getCapabilities(); - expect( - FakeMatrixApi.api['GET']!['/client/v3/capabilities']! - .call(emptyRequest), - {'capabilities': response.toJson()}); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('uploadFilter', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = - await matrixApi.defineFilter('alice@example.com', Filter()); - expect(response, '1234'); - final filter = Filter( - room: RoomFilter( - notRooms: ['!1234'], - rooms: ['!1234'], - ephemeral: StateFilter( - limit: 10, - senders: ['@alice:example.com'], - types: ['type1'], - notTypes: ['type2'], - notRooms: ['!1234'], - notSenders: ['@bob:example.com'], - lazyLoadMembers: true, - includeRedundantMembers: false, - containsUrl: true, - ), - includeLeave: true, - state: StateFilter(), - timeline: StateFilter(), - accountData: StateFilter(limit: 10, types: ['type1']), - ), - presence: StateFilter( - limit: 10, - senders: ['@alice:example.com'], - types: ['type1'], - notRooms: ['!1234'], - notSenders: ['@bob:example.com'], - ), - eventFormat: EventFormat.client, - eventFields: ['type', 'content', 'sender'], - accountData: EventFilter( - types: ['m.accountdatatest'], - notSenders: ['@alice:example.com'], - ), - ); - expect(filter.toJson(), { - 'room': { - 'not_rooms': ['!1234'], - 'rooms': ['!1234'], - 'ephemeral': { - 'limit': 10, - 'senders': ['@alice:example.com'], - 'types': ['type1'], - 'not_rooms': ['!1234'], - 'not_senders': ['@bob:example.com'], - 'not_types': ['type2'], - 'lazy_load_members': true, - 'include_redundant_members': false, - 'contains_url': true, - }, - 'account_data': { - 'limit': 10, - 'types': ['type1'], - }, - 'include_leave': true, - 'state': {}, - 'timeline': {}, - }, - 'presence': { - 'limit': 10, - 'senders': ['@alice:example.com'], - 'types': ['type1'], - 'not_rooms': ['!1234'], - 'not_senders': ['@bob:example.com'] - }, - 'event_format': 'client', - 'event_fields': ['type', 'content', 'sender'], - 'account_data': { - 'types': ['m.accountdatatest'], - 'not_senders': ['@alice:example.com'] - }, - }); - await matrixApi.defineFilter( - 'alice@example.com', - filter, - ); - final filterMap = { - 'room': { - 'state': { - 'types': ['m.room.*'], - 'not_rooms': ['!726s6s6q:example.com'] - }, - 'timeline': { - 'limit': 10, - 'types': ['m.room.message'], - 'not_rooms': ['!726s6s6q:example.com'], - 'not_senders': ['@spam:example.com'] - }, - 'ephemeral': { - 'types': ['m.receipt', 'm.typing'], - 'not_rooms': ['!726s6s6q:example.com'], - 'not_senders': ['@spam:example.com'] - } - }, - 'presence': { - 'types': ['m.presence'], - 'not_senders': ['@alice:example.com'] - }, - 'account_data': { - 'types': ['m.accountdatatest'], - 'not_senders': ['@alice:example.com'] - }, - 'event_format': 'client', - 'event_fields': ['type', 'content', 'sender'] - }; - expect(filterMap, Filter.fromJson(filterMap).toJson()); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('downloadFilter', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - await matrixApi.getFilter('alice@example.com', '1234'); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('sync', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = await matrixApi.sync( - filter: '{}', - since: '1234', - fullState: false, - setPresence: PresenceType.unavailable, - timeout: 15, - ); - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/sync?filter=%7B%7D&since=1234&full_state=false&set_presence=unavailable&timeout=15']! - .call(emptyRequest) as Map?, - response.toJson()); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestEvent', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final event = - await matrixApi.getOneRoomEvent('!localpart:server.abc', '1234'); - expect(event.eventId, '143273582443PhrSn:example.org'); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('getRoomStateWithKey', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.getRoomStateWithKey( - '!localpart:server.abc', - 'm.room.member', - '@getme:example.com', - ); - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestStates', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final states = await matrixApi.getRoomState('!localpart:server.abc'); - expect(states.length, 4); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestMembers', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final states = await matrixApi.getMembersByRoom( - '!localpart:server.abc', - at: '1234', - membership: Membership.join, - notMembership: Membership.leave, - ); - expect(states?.length, 1); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestJoinedMembers', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final states = await matrixApi.getJoinedMembersByRoom( - '!localpart:server.abc', - ); - expect(states?.length, 1); - expect(states?['@bar:example.com']?.toJson(), { - 'display_name': 'Bar', - 'avatar_url': 'mxc://riot.ovh/printErCATzZijQsSDWorRaK' - }); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestMessages', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final timelineHistoryResponse = await matrixApi.getRoomEvents( - '!localpart:server.abc', - Direction.b, - from: '1234', - limit: 10, - filter: '{"lazy_load_members":true}', - to: '1234', - ); - - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/rooms/!localpart%3Aserver.abc/messages?from=1234&to=1234&dir=b&limit=10&filter=%7B%22lazy_load_members%22%3Atrue%7D']! - .call(emptyRequest) as Map?, - timelineHistoryResponse.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('sendState', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final eventId = await matrixApi.setRoomStateWithKey( - '!localpart:server.abc', 'm.room.avatar', '', {'url': 'mxc://1234'}); - - expect(eventId, 'YUwRidLecu:example.com'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('sendMessage', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final eventId = await matrixApi.sendMessage( - '!localpart:server.abc', - 'm.room.message', - '1234', - {'body': 'hello world', 'msgtype': 'm.text'}, - ); - - expect(eventId, 'YUwRidLecu:example.com'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('redact', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final eventId = await matrixApi.redactEvent( - '!localpart:server.abc', - '1234', - '1234', - reason: 'hello world', - ); - - expect(eventId, 'YUwRidLecu:example.com'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('createRoom', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = await matrixApi.createRoom( - visibility: Visibility.public, - roomAliasName: '#testroom:example.com', - name: 'testroom', - topic: 'just for testing', - invite: ['@bob:example.com'], - invite3pid: [], - roomVersion: '2', - creationContent: {}, - initialState: [], - preset: CreateRoomPreset.publicChat, - isDirect: false, - powerLevelContentOverride: {}, - ); - - expect(roomId, '!1234:fakeServer.notExisting'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('createRoomAlias', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setRoomAlias( - '#testalias:example.com', - '!1234:example.com', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestRoomAliasInformation', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomAliasInformation = await matrixApi.getRoomIdByAlias( - '#testalias:example.com', - ); - - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/directory/room/%23testalias%3Aexample.com']! - .call(emptyRequest), - roomAliasInformation.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('removeRoomAlias', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.deleteRoomAlias('#testalias:example.com'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestRoomAliases', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final list = await matrixApi.getLocalAliases('!localpart:example.com'); - expect(list.length, 3); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestJoinedRooms', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final list = await matrixApi.getJoinedRooms(); - expect(list.length, 1); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('inviteUser', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.inviteUser('!localpart:example.com', '@bob:example.com'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('joinRoom', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = '!localpart:example.com'; - final response = await matrixApi.joinRoomById( - roomId, - thirdPartySigned: ThirdPartySigned( - sender: '@bob:example.com', - mxid: '@alice:example.com', - token: '1234', - signatures: { - 'example.org': {'ed25519:0': 'some9signature'} - }, - ), - ); - expect(response, roomId); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('joinRoomOrAlias', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = '!localpart:example.com'; - final response = await matrixApi.joinRoom( - roomId, - serverName: ['example.com', 'example.abc'], - thirdPartySigned: ThirdPartySigned( - sender: '@bob:example.com', - mxid: '@alice:example.com', - token: '1234', - signatures: { - 'example.org': {'ed25519:0': 'some9signature'} - }, - ), - ); - expect(response, roomId); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('leave', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.leaveRoom('!localpart:example.com'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('forget', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.forgetRoom('!localpart:example.com'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('kickFromRoom', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.kick( - '!localpart:example.com', - '@bob:example.com', - reason: 'test', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('banFromRoom', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.ban( - '!localpart:example.com', - '@bob:example.com', - reason: 'test', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('unbanInRoom', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.unban( - '!localpart:example.com', - '@bob:example.com', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestRoomVisibility', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final visibility = await matrixApi - .getRoomVisibilityOnDirectory('!localpart:example.com'); - expect(visibility, Visibility.public); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('setRoomVisibility', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setRoomVisibilityOnDirectory('!localpart:example.com', - visibility: Visibility.private); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestPublicRooms', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getPublicRooms( - limit: 10, - since: '1234', - server: 'example.com', - ); - - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/publicRooms?limit=10&since=1234&server=example.com']! - .call(emptyRequest), - response.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('searchPublicRooms', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.queryPublicRooms( - limit: 10, - since: '1234', - server: 'example.com', - filter: PublicRoomQueryFilter( - genericSearchTerm: 'test', - ), - includeAllNetworks: false, - thirdPartyInstanceId: 'id', - ); - - expect( - FakeMatrixApi - .api['POST']!['/client/v3/publicRooms?server=example.com']! - .call(emptyRequest), - response.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('getSpaceHierarchy', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = - await matrixApi.getSpaceHierarchy('!gPxZhKUssFZKZcoCKY:neko.dev'); - - expect( - FakeMatrixApi.api['GET']![ - '/client/v1/rooms/${Uri.encodeComponent('!gPxZhKUssFZKZcoCKY:neko.dev')}/hierarchy']! - .call(emptyRequest), - response.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('searchUser', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.searchUserDirectory( - 'test', - limit: 10, - ); - - expect( - FakeMatrixApi.api['POST']!['/client/v3/user_directory/search']! - .call(emptyRequest), - response.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('setDisplayname', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setDisplayName('@alice:example.com', 'Alice M'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestDisplayname', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.getDisplayName('@alice:example.com'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('setAvatarUrl', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setAvatarUrl( - '@alice:example.com', - Uri.parse('mxc://test'), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestAvatarUrl', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getAvatarUrl('@alice:example.com'); - expect(response, Uri.parse('mxc://test')); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestProfile', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getUserProfile('@alice:example.com'); - expect( - FakeMatrixApi - .api['GET']!['/client/v3/profile/%40alice%3Aexample.com']! - .call(emptyRequest), - response.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestTurnServerCredentials', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getTurnServer(); - expect( - FakeMatrixApi.api['GET']!['/client/v3/voip/turnServer']! - .call(emptyRequest), - response.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('sendTypingNotification', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setTyping( - '@alice:example.com', - '!localpart:example.com', - true, - timeout: 10, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('sendReceiptMarker', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.postReceipt( - '!localpart:example.com', - ReceiptType.mRead, - '\$1234:example.com', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('sendReadMarker', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setReadMarker( - '!localpart:example.com', - mFullyRead: '\$1234:example.com', - mRead: '\$1234:example.com', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('sendPresence', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setPresence( - '@alice:example.com', - PresenceType.offline, - statusMsg: 'test', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestPresence', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getPresence( - '@alice:example.com', - ); - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/presence/${Uri.encodeComponent('@alice:example.com')}/status']! - .call(emptyRequest), - response.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('upload', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - final response = - await matrixApi.uploadContent(Uint8List(0), filename: 'file.jpeg'); - expect(response, Uri.parse('mxc://example.com/AQwafuaFswefuhsfAFAgsw')); - var throwsException = false; - try { - await matrixApi.uploadContent(Uint8List(0), filename: 'file.jpg'); - } catch (_) { - throwsException = true; - } - expect(throwsException, true); - matrixApi.homeserver = null; - }); - test('requestOpenGraphDataForUrl', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final openGraphData = await matrixApi.getUrlPreview( - Uri.parse('https://matrix.org'), - ts: 10, - ); - expect( - FakeMatrixApi.api['GET']![ - '/media/v3/preview_url?url=https%3A%2F%2Fmatrix.org&ts=10']! - .call(emptyRequest), - openGraphData.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('getConfig', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getConfig(); - expect(response.mUploadSize, 50000000); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('sendToDevice', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.sendToDevice('m.test', '1234', { - '@alice:example.com': { - 'TLLBEANAAG': {'example_content_key': 'value'} - } - }); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestDevices', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final devices = await matrixApi.getDevices(); - expect( - (FakeMatrixApi.api['GET']!['/client/v3/devices']!.call(emptyRequest) - as Map?)?['devices'], - devices?.map((i) => i.toJson()).toList()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestDevice', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.getDevice('QBUAZIFURK'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('setDeviceMetadata', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.updateDevice('QBUAZIFURK', displayName: 'test'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('deleteDevice', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.deleteDevice('QBUAZIFURK'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('deleteDevices', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.deleteDevices(['QBUAZIFURK']); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('uploadDeviceKeys', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.uploadKeys( - deviceKeys: MatrixDeviceKeys( - '@alice:example.com', - 'ABCD', - ['caesar-chiffre'], - {}, - {}, - unsigned: {}, - ), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestDeviceKeys', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.queryKeys( - { - '@alice:example.com': [], - }, - timeout: 10, - token: '1234', - ); - expect( - response.deviceKeys!['@alice:example.com']!['JLAFKJWSCS']! - .deviceDisplayName, - 'Alices mobile phone'); - expect( - FakeMatrixApi.api['POST']!['/client/v3/keys/query']! - .call({'device_keys': emptyRequest}), - response.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestOneTimeKeys', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.claimKeys( - { - '@alice:example.com': {'JLAFKJWSCS': 'signed_curve25519'} - }, - timeout: 10, - ); - expect( - FakeMatrixApi.api['POST']!['/client/v3/keys/claim']!.call({ - 'one_time_keys': { - '@alice:example.com': {'JLAFKJWSCS': 'signed_curve25519'} - } - }), - response.toJson()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestDeviceListsUpdate', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.getKeysChanges('1234', '1234'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('uploadCrossSigningKeys', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final masterKey = MatrixCrossSigningKey.fromJson({ - 'user_id': '@test:fakeServer.notExisting', - 'usage': ['master'], - 'keys': { - 'ed25519:82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8': - '82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8', - }, - 'signatures': >{}, - }); - final selfSigningKey = MatrixCrossSigningKey.fromJson({ - 'user_id': '@test:fakeServer.notExisting', - 'usage': ['self_signing'], - 'keys': { - 'ed25519:F9ypFzgbISXCzxQhhSnXMkc1vq12Luna3Nw5rqViOJY': - 'F9ypFzgbISXCzxQhhSnXMkc1vq12Luna3Nw5rqViOJY', - }, - 'signatures': >{}, - }); - final userSigningKey = MatrixCrossSigningKey.fromJson({ - 'user_id': '@test:fakeServer.notExisting', - 'usage': ['user_signing'], - 'keys': { - 'ed25519:0PiwulzJ/RU86LlzSSZ8St80HUMN3dqjKa/orIJoA0g': - '0PiwulzJ/RU86LlzSSZ8St80HUMN3dqjKa/orIJoA0g', - }, - 'signatures': >{}, - }); - await matrixApi.uploadCrossSigningKeys( - masterKey: masterKey, - selfSigningKey: selfSigningKey, - userSigningKey: userSigningKey); - }); - test('requestPushers', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getPushers(); - expect( - FakeMatrixApi.api['GET']!['/client/v3/pushers']! - .call({}), - {'pushers': response?.map((i) => i.toJson()).toList()}, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('setPusher', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.postPusher( - Pusher( - pushkey: '1234', - appId: 'app.id', - appDisplayName: 'appDisplayName', - deviceDisplayName: 'deviceDisplayName', - lang: 'en', - data: PusherData( - format: 'event_id_only', url: Uri.parse('https://matrix.org')), - profileTag: 'tag', - kind: 'http', - ), - append: true, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestNotifications', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getNotifications( - from: '1234', - limit: 10, - only: '1234', - ); - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/notifications?from=1234&limit=10&only=1234']! - .call({}), - response.toJson(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestPushRules', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getPushRules(); - expect( - FakeMatrixApi.api['GET']!['/client/v3/pushrules']! - .call({}), - {'global': response.toJson()}, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestPushRule', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = - await matrixApi.getPushRule('global', PushRuleKind.content, 'nocake'); - expect( - FakeMatrixApi.api['GET']!['/client/v3/pushrules/global/content/nocake']! - .call({}), - response.toJson(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('deletePushRule', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.deletePushRule('global', PushRuleKind.content, 'nocake'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('setPushRule', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setPushRule( - 'global', - PushRuleKind.content, - 'nocake', - [PushRuleAction.notify], - before: '1', - after: '2', - conditions: [ - PushCondition( - kind: 'event_match', - key: 'key', - pattern: 'pattern', - is$: '+', - ) - ], - pattern: 'pattern', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestPushRuleEnabled', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final enabled = await matrixApi.isPushRuleEnabled( - 'global', PushRuleKind.content, 'nocake'); - expect(enabled, true); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('enablePushRule', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setPushRuleEnabled( - 'global', - PushRuleKind.content, - 'nocake', - true, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestPushRuleActions', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final actions = await matrixApi.getPushRuleActions( - 'global', PushRuleKind.content, 'nocake'); - expect(actions.first, PushRuleAction.notify); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('setPushRuleActions', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setPushRuleActions( - 'global', - PushRuleKind.content, - 'nocake', - [PushRuleAction.dontNotify], - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('globalSearch', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.search(Categories()); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('globalSearch', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.peekEvents( - from: '1234', roomId: '!1234', timeout: 10); - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/events?from=1234&timeout=10&room_id=%211234']! - .call({}), - response.toJson(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestRoomTags', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getRoomTags( - '@alice:example.com', '!localpart:example.com'); - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/user/%40alice%3Aexample.com/rooms/!localpart%3Aexample.com/tags']! - .call({}), - {'tags': response?.map((k, v) => MapEntry(k, v.toJson()))}, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('addRoomTag', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setRoomTag( - '@alice:example.com', - '!localpart:example.com', - 'testtag', - order: 0.5, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('addRoomTag', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.deleteRoomTag( - '@alice:example.com', - '!localpart:example.com', - 'testtag', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('setAccountData', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setAccountData( - '@alice:example.com', - 'test.account.data', - {'foo': 'bar'}, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestAccountData', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.getAccountData( - '@alice:example.com', - 'test.account.data', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('setRoomAccountData', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.setAccountDataPerRoom( - '@alice:example.com', - '1234', - 'test.account.data', - {'foo': 'bar'}, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestRoomAccountData', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.getAccountDataPerRoom( - '@alice:example.com', - '1234', - 'test.account.data', - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestWhoIsInfo', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getWhoIs('@alice:example.com'); - expect( - FakeMatrixApi - .api['GET']!['/client/v3/admin/whois/%40alice%3Aexample.com']! - .call(emptyRequest), - response.toJson(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestEventContext', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getEventContext('1234', '1234', - limit: 10, filter: '{}'); - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/rooms/1234/context/1234?limit=10&filter=%7B%7D']! - .call(emptyRequest), - response.toJson(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('reportEvent', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.reportContent( - '1234', - '1234', - reason: 'test', - score: -100, - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('getProtocols', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getProtocols(); - expect( - FakeMatrixApi.api['GET']!['/client/v3/thirdparty/protocols']! - .call(emptyRequest), - response.map((k, v) => MapEntry(k, v.toJson())), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('getProtocol', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.getProtocolMetadata('irc'); - expect( - FakeMatrixApi.api['GET']!['/client/v3/thirdparty/protocol/irc']! - .call(emptyRequest), - response.toJson(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('queryLocationByProtocol', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.queryLocationByProtocol('irc'); - expect( - FakeMatrixApi.api['GET']!['/client/v3/thirdparty/location/irc']! - .call(emptyRequest), - response.map((i) => i.toJson()).toList(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('queryUserByProtocol', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.queryUserByProtocol('irc'); - expect( - FakeMatrixApi.api['GET']!['/client/v3/thirdparty/user/irc']! - .call(emptyRequest), - response.map((i) => i.toJson()).toList(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('queryLocationByAlias', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.queryLocationByAlias('1234'); - expect( - FakeMatrixApi.api['GET']!['/client/v3/thirdparty/location?alias=1234']! - .call(emptyRequest), - response.map((i) => i.toJson()).toList(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('queryUserByID', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.queryUserByID('1234'); - expect( - FakeMatrixApi.api['GET']!['/client/v3/thirdparty/user?userid=1234']! - .call(emptyRequest), - response.map((i) => i.toJson()).toList(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('requestOpenIdCredentials', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final response = await matrixApi.requestOpenIdToken('1234', {}); - expect( - FakeMatrixApi.api['POST']!['/client/v3/user/1234/openid/request_token']! - .call(emptyRequest), - response.toJson(), - ); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('upgradeRoom', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.upgradeRoom('1234', '2'); - - matrixApi.homeserver = matrixApi.accessToken = null; - }); - test('postRoomKeysVersion', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2; - final authData = { - 'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM', - 'signatures': >{}, - }; - final ret = await matrixApi.postRoomKeysVersion(algorithm, authData); - expect( - (FakeMatrixApi.api['POST']!['/client/v3/room_keys/version']! - .call(emptyRequest) as Map)['version'], - ret); - }); - test('getRoomKeysVersionCurrent', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final ret = await matrixApi.getRoomKeysVersionCurrent(); - expect( - FakeMatrixApi.api['GET']!['/client/v3/room_keys/version']! - .call(emptyRequest), - ret.toJson()); - }); - test('putRoomKeysVersion', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2; - final authData = { - 'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM', - 'signatures': >{}, - }; - await matrixApi.putRoomKeysVersion('5', algorithm, authData); - }); - test('deleteRoomKeys', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - await matrixApi.deleteRoomKeys('5'); - }); - test('putRoomKeyBySessionId', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = '!726s6s6q:example.com'; - final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; - final session = KeyBackupData.fromJson({ - 'first_message_index': 0, - 'forwarded_count': 0, - 'is_verified': true, - 'session_data': { - 'ephemeral': 'fwRxYh+seqLykz5mQCLypJ4/59URdcFJ2s69OU1dGRc', - 'ciphertext': - '19jkQYlbgdP+VL9DH3qY/Dvpk6onJZgf+6frZFl1TinPCm9OMK9AZZLuM1haS9XLAUK1YsREgjBqfl6T+Tq8JlJ5ONZGg2Wttt24sGYc0iTMZJ8rXcNDeKMZhM96ETyjufJSeYoXLqifiVLDw9rrVBmNStF7PskYp040em+0OZ4pF85Cwsdf7l9V7MMynzh9BoXqVUCBiwT03PNYH9AEmNUxXX+6ZwCpe/saONv8MgGt5uGXMZIK29phA3D8jD6uV/WOHsB8NjHNq9FrfSEAsl+dAcS4uiYie4BKSSeQN+zGAQqu1MMW4OAdxGOuf8WpIINx7n+7cKQfxlmc/Cgg5+MmIm2H0oDwQ+Xu7aSxp1OCUzbxQRdjz6+tnbYmZBuH0Ov2RbEvC5tDb261LRqKXpub0llg5fqKHl01D0ahv4OAQgRs5oU+4mq+H2QGTwIFGFqP9tCRo0I+aICawpxYOfoLJpFW6KvEPnM2Lr3sl6Nq2fmkz6RL5F7nUtzxN8OKazLQpv8DOYzXbi7+ayEsqS0/EINetq7RfCqgjrEUgfNWYuFXWqvUT8lnxLdNu+8cyrJqh1UquFjXWTw1kWcJ0pkokVeBtK9YysCnF1UYh/Iv3rl2ZoYSSLNtuvMSYlYHggZ8xV8bz9S3X2/NwBycBiWIy5Ou/OuSX7trIKgkkmda0xjBWEM1a2acVuqu2OFbMn2zFxm2a3YwKP//OlIgMg', - 'mac': 'QzKV/fgAs4U', - }, - }); - final ret = await matrixApi.putRoomKeyBySessionId( - roomId, sessionId, '5', session); - expect( - FakeMatrixApi.api['PUT']![ - '/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']! - .call(emptyRequest), - ret.toJson()); - }); - test('getRoomKeyBySessionId', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = '!726s6s6q:example.com'; - final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; - final ret = await matrixApi.getRoomKeyBySessionId(roomId, sessionId, '5'); - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']! - .call(emptyRequest), - ret.toJson()); - }); - test('deleteRoomKeyBySessionId', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = '!726s6s6q:example.com'; - final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; - final ret = - await matrixApi.deleteRoomKeyBySessionId(roomId, sessionId, '5'); - expect( - FakeMatrixApi.api['DELETE']![ - '/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']! - .call(emptyRequest), - ret.toJson()); - }); - test('putRoomKeysByRoomId', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = '!726s6s6q:example.com'; - final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; - final session = RoomKeyBackup.fromJson({ - 'sessions': { - sessionId: { - 'first_message_index': 0, - 'forwarded_count': 0, - 'is_verified': true, - 'session_data': { - 'ephemeral': 'fwRxYh+seqLykz5mQCLypJ4/59URdcFJ2s69OU1dGRc', - 'ciphertext': - '19jkQYlbgdP+VL9DH3qY/Dvpk6onJZgf+6frZFl1TinPCm9OMK9AZZLuM1haS9XLAUK1YsREgjBqfl6T+Tq8JlJ5ONZGg2Wttt24sGYc0iTMZJ8rXcNDeKMZhM96ETyjufJSeYoXLqifiVLDw9rrVBmNStF7PskYp040em+0OZ4pF85Cwsdf7l9V7MMynzh9BoXqVUCBiwT03PNYH9AEmNUxXX+6ZwCpe/saONv8MgGt5uGXMZIK29phA3D8jD6uV/WOHsB8NjHNq9FrfSEAsl+dAcS4uiYie4BKSSeQN+zGAQqu1MMW4OAdxGOuf8WpIINx7n+7cKQfxlmc/Cgg5+MmIm2H0oDwQ+Xu7aSxp1OCUzbxQRdjz6+tnbYmZBuH0Ov2RbEvC5tDb261LRqKXpub0llg5fqKHl01D0ahv4OAQgRs5oU+4mq+H2QGTwIFGFqP9tCRo0I+aICawpxYOfoLJpFW6KvEPnM2Lr3sl6Nq2fmkz6RL5F7nUtzxN8OKazLQpv8DOYzXbi7+ayEsqS0/EINetq7RfCqgjrEUgfNWYuFXWqvUT8lnxLdNu+8cyrJqh1UquFjXWTw1kWcJ0pkokVeBtK9YysCnF1UYh/Iv3rl2ZoYSSLNtuvMSYlYHggZ8xV8bz9S3X2/NwBycBiWIy5Ou/OuSX7trIKgkkmda0xjBWEM1a2acVuqu2OFbMn2zFxm2a3YwKP//OlIgMg', - 'mac': 'QzKV/fgAs4U', - }, - }, - }, - }); - final ret = await matrixApi.putRoomKeysByRoomId(roomId, '5', session); - expect( - FakeMatrixApi.api['PUT']![ - '/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']! - .call(emptyRequest), - ret.toJson()); - }); - test('getRoomKeysByRoomId', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = '!726s6s6q:example.com'; - final ret = await matrixApi.getRoomKeysByRoomId(roomId, '5'); - expect( - FakeMatrixApi.api['GET']![ - '/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']! - .call(emptyRequest), - ret.toJson()); - }); - test('deleteRoomKeysByRoomId', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = '!726s6s6q:example.com'; - final ret = await matrixApi.deleteRoomKeysByRoomId(roomId, '5'); - expect( - FakeMatrixApi.api['DELETE']![ - '/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']! - .call(emptyRequest), - ret.toJson()); - }); - test('putRoomKeys', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final roomId = '!726s6s6q:example.com'; - final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; - final session = RoomKeys.fromJson({ - 'rooms': { - roomId: { - 'sessions': { - sessionId: { - 'first_message_index': 0, - 'forwarded_count': 0, - 'is_verified': true, - 'session_data': { - 'ephemeral': 'fwRxYh+seqLykz5mQCLypJ4/59URdcFJ2s69OU1dGRc', - 'ciphertext': - '19jkQYlbgdP+VL9DH3qY/Dvpk6onJZgf+6frZFl1TinPCm9OMK9AZZLuM1haS9XLAUK1YsREgjBqfl6T+Tq8JlJ5ONZGg2Wttt24sGYc0iTMZJ8rXcNDeKMZhM96ETyjufJSeYoXLqifiVLDw9rrVBmNStF7PskYp040em+0OZ4pF85Cwsdf7l9V7MMynzh9BoXqVUCBiwT03PNYH9AEmNUxXX+6ZwCpe/saONv8MgGt5uGXMZIK29phA3D8jD6uV/WOHsB8NjHNq9FrfSEAsl+dAcS4uiYie4BKSSeQN+zGAQqu1MMW4OAdxGOuf8WpIINx7n+7cKQfxlmc/Cgg5+MmIm2H0oDwQ+Xu7aSxp1OCUzbxQRdjz6+tnbYmZBuH0Ov2RbEvC5tDb261LRqKXpub0llg5fqKHl01D0ahv4OAQgRs5oU+4mq+H2QGTwIFGFqP9tCRo0I+aICawpxYOfoLJpFW6KvEPnM2Lr3sl6Nq2fmkz6RL5F7nUtzxN8OKazLQpv8DOYzXbi7+ayEsqS0/EINetq7RfCqgjrEUgfNWYuFXWqvUT8lnxLdNu+8cyrJqh1UquFjXWTw1kWcJ0pkokVeBtK9YysCnF1UYh/Iv3rl2ZoYSSLNtuvMSYlYHggZ8xV8bz9S3X2/NwBycBiWIy5Ou/OuSX7trIKgkkmda0xjBWEM1a2acVuqu2OFbMn2zFxm2a3YwKP//OlIgMg', - 'mac': 'QzKV/fgAs4U', - }, - }, - }, - }, - }, - }); - final ret = await matrixApi.putRoomKeys('5', session); - expect( - FakeMatrixApi.api['PUT']!['/client/v3/room_keys/keys?version=5']! - .call(emptyRequest), - ret.toJson()); - }); - test('getRoomKeys', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final ret = await matrixApi.getRoomKeys('5'); - expect( - FakeMatrixApi.api['GET']!['/client/v3/room_keys/keys?version=5']! - .call(emptyRequest), - ret.toJson()); - }); - test('deleteRoomKeys', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final ret = await matrixApi.deleteRoomKeys('5'); - expect( - FakeMatrixApi.api['DELETE']!['/client/v3/room_keys/keys?version=5']! - .call(emptyRequest), - ret.toJson()); - }); - test('AuthenticationData', () { - final json = {'session': '1234', 'type': 'm.login.dummy'}; - expect(AuthenticationData.fromJson(json).toJson(), json); - expect( - AuthenticationData(session: '1234', type: 'm.login.dummy').toJson(), - json); - }); - test('AuthenticationRecaptcha', () { - final json = { - 'session': '1234', - 'type': 'm.login.recaptcha', - 'response': 'a', - }; - expect(AuthenticationRecaptcha.fromJson(json).toJson(), json); - expect(AuthenticationRecaptcha(session: '1234', response: 'a').toJson(), - json); - }); - test('AuthenticationToken', () { - final json = { - 'session': '1234', - 'type': 'm.login.token', - 'token': 'a', - 'txn_id': '1' - }; - expect(AuthenticationToken.fromJson(json).toJson(), json); - expect( - AuthenticationToken(session: '1234', token: 'a', txnId: '1').toJson(), - json); - }); - test('AuthenticationThreePidCreds', () { - final json = { - 'type': 'm.login.email.identity', - 'threepid_creds': { - 'sid': '1', - 'client_secret': 'a', - 'id_server': 'matrix.org', - 'id_access_token': 'a', - }, - 'session': '1', - }; - expect(AuthenticationThreePidCreds.fromJson(json).toJson(), json); - expect( - AuthenticationThreePidCreds( - session: '1', - type: AuthenticationTypes.emailIdentity, - threepidCreds: ThreepidCreds( - sid: '1', - clientSecret: 'a', - idServer: 'matrix.org', - idAccessToken: 'a', - ), - ).toJson(), - json); - }); - test('AuthenticationIdentifier', () { - final json = {'type': 'm.id.user'}; - expect(AuthenticationIdentifier.fromJson(json).toJson(), json); - expect(AuthenticationIdentifier(type: 'm.id.user').toJson(), json); - }); - test('AuthenticationPassword', () { - final json = { - 'type': 'm.login.password', - 'identifier': {'type': 'm.id.user', 'user': 'a'}, - 'password': 'a', - 'session': '1', - }; - expect(AuthenticationPassword.fromJson(json).toJson(), json); - expect( - AuthenticationPassword( - session: '1', - password: 'a', - identifier: AuthenticationUserIdentifier(user: 'a'), - ).toJson(), - json); - json['identifier'] = { - 'type': 'm.id.thirdparty', - 'medium': 'a', - 'address': 'a', - }; - expect(AuthenticationPassword.fromJson(json).toJson(), json); - expect( - AuthenticationPassword( - session: '1', - password: 'a', - identifier: - AuthenticationThirdPartyIdentifier(medium: 'a', address: 'a'), - ).toJson(), - json); - json['identifier'] = { - 'type': 'm.id.phone', - 'country': 'a', - 'phone': 'a', - }; - expect(AuthenticationPassword.fromJson(json).toJson(), json); - expect( - AuthenticationPassword( - session: '1', - password: 'a', - identifier: AuthenticationPhoneIdentifier(country: 'a', phone: 'a'), - ).toJson(), - json); - }); - }); -} diff --git a/test/try_get_map_extension_test.dart b/test/try_get_map_extension_test.dart deleted file mode 100644 index 9f1a51d2..00000000 --- a/test/try_get_map_extension_test.dart +++ /dev/null @@ -1,52 +0,0 @@ -/* MIT License -* -* Copyright (C) 2019, 2020, 2021 Famedly GmbH -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all -* copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -import 'package:test/test.dart'; - -import 'package:matrix_api_lite/matrix_api_lite.dart'; - -void main() { - group('Try-get-map-extension', () { - Logs().level = Level.verbose; - test('it should work', () { - final data = { - 'str': 'foxies', - 'int': 42, - 'list': [2, 3, 4], - 'map': { - 'beep': 'boop', - }, - }; - expect(data.tryGet('str'), 'foxies'); - expect(data.tryGet('str'), null); - expect(data.tryGet('int'), 42); - expect(data.tryGet>('list'), [2, 3, 4]); - expect(data.tryGetMap('map')?.tryGet('beep'), - 'boop'); - expect( - data.tryGetMap('map')?.tryGet('meep'), null); - expect( - data.tryGetMap('pam')?.tryGet('beep'), null); - }); - }); -}