specter-desktop/tests/test_util_reflection.py

181 lines
6.9 KiB
Python
Raw Normal View History

Feature: Service integration - Swan (#1517) * fix create_order issue * fix url and better error-handling * basic balances tab * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * fix controller-test * fix singleton testing issues Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 04:47:28 -06:00
import logging
Feature: several things for Spectrum preparation (#1913) * change Node persistence format * Removing the Singleton * mainly refactoring * intermediate commit * fix test * Updated diagram * fix tests * removing simplejsons references * fix tests * remove update, tests working * abstract Node * refining Migration framework: run migrations until they suceed * BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes * clicking redirects to node config if there is no node connection * AbstractNode * BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes * clicking redirects to node config if there is no node connection * handling broken connection when there is no other error superseding (i.e. no wallets) * Abstract Node improvements and issue fixing * improving node_info handling * fix test results, property device_manager in user, bcce in get_rpc in node, improved rpc property in node * typos * provide data_folders for extensions * parametrizing include for node_info * Remove initial_node_contribution refactoring welcome * adding convenience methods * extension data-storage * Tests green * Better failure resistence * Enabling Node settings * error handling * adjust_view_model callback * exception Handling * Shielding core from extension flaws * More consistent logging * Refactoring wallets endpoints * Make wallet_overview extendable * butgifex and cleanup * feedback by Manolis * rename BusinessObject to PersistentObject * fix Error-management and rollback information * Nodes.md corrections * frontend-aspects.md (small) corrections * fix tests and address feedback and errormanagement * fix tests, proper error-handling * Fix test_util_reflection * just some little addons to test_util_reflection * fix cleanup_on_exit * migration fix * remove check, add redirect after saving node * fix test (not that cool but what to do?) * upgrade Flask as Flask-SQLAlchemy needs higher Flask version * Revert "upgrade Flask as Flask-SQLAlchemy needs higher Flask version" This reverts commit bf24120f891f2589bd0fd3ddb3df002323181553. * update bug fixed + node manager added to node test * cleanup external_node Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-10-29 15:54:34 +02:00
import pytest
Feature: Service integration - Swan (#1517) * fix create_order issue * fix url and better error-handling * basic balances tab * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * fix controller-test * fix singleton testing issues Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 04:47:28 -06:00
from pathlib import Path
from typing import List
from cryptoadvance.specter.device import Device
from cryptoadvance.specter.devices.bitbox02 import BitBox02
from cryptoadvance.specter.specter_error import SpecterInternalException
from cryptoadvance.specter.util.migrations.migration_0001 import SpecterMigration_0001
Feature: Service integration - Swan (#1517) * fix create_order issue * fix url and better error-handling * basic balances tab * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * fix controller-test * fix singleton testing issues Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 04:47:28 -06:00
from cryptoadvance.specter.util.reflection import (
Feature: several things for Spectrum preparation (#1913) * change Node persistence format * Removing the Singleton * mainly refactoring * intermediate commit * fix test * Updated diagram * fix tests * removing simplejsons references * fix tests * remove update, tests working * abstract Node * refining Migration framework: run migrations until they suceed * BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes * clicking redirects to node config if there is no node connection * AbstractNode * BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes * clicking redirects to node config if there is no node connection * handling broken connection when there is no other error superseding (i.e. no wallets) * Abstract Node improvements and issue fixing * improving node_info handling * fix test results, property device_manager in user, bcce in get_rpc in node, improved rpc property in node * typos * provide data_folders for extensions * parametrizing include for node_info * Remove initial_node_contribution refactoring welcome * adding convenience methods * extension data-storage * Tests green * Better failure resistence * Enabling Node settings * error handling * adjust_view_model callback * exception Handling * Shielding core from extension flaws * More consistent logging * Refactoring wallets endpoints * Make wallet_overview extendable * butgifex and cleanup * feedback by Manolis * rename BusinessObject to PersistentObject * fix Error-management and rollback information * Nodes.md corrections * frontend-aspects.md (small) corrections * fix tests and address feedback and errormanagement * fix tests, proper error-handling * Fix test_util_reflection * just some little addons to test_util_reflection * fix cleanup_on_exit * migration fix * remove check, add redirect after saving node * fix test (not that cool but what to do?) * upgrade Flask as Flask-SQLAlchemy needs higher Flask version * Revert "upgrade Flask as Flask-SQLAlchemy needs higher Flask version" This reverts commit bf24120f891f2589bd0fd3ddb3df002323181553. * update bug fixed + node manager added to node test * cleanup external_node Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-10-29 15:54:34 +02:00
get_class,
Bugfix: Very last fixes for Service swan (#1537) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh * Refactor service_manager and templates where they belong to * Swan - different fronend-links links for dev/prod * include templates and services in sdist * implement dynamic loading but from list in config * No dynamic cwd services in appimages * tidy up Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: kdmukai <kdmukai@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-26 22:11:26 +01:00
get_subclasses_for_clazz,
get_subclasses_for_clazz_in_cwd,
Bugfix: Very last fixes for Service swan (#1537) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh * Refactor service_manager and templates where they belong to * Swan - different fronend-links links for dev/prod * include templates and services in sdist * implement dynamic loading but from list in config * No dynamic cwd services in appimages * tidy up Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: kdmukai <kdmukai@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-26 22:11:26 +01:00
get_classlist_of_type_clazz_from_modulelist,
is_specter_desktop_project,
Feature: Service integration - Swan (#1517) * fix create_order issue * fix url and better error-handling * basic balances tab * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * fix controller-test * fix singleton testing issues Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 04:47:28 -06:00
_get_module_from_class,
get_package_dir_for_subclasses_of,
search_dirs_in_path,
Feature: Service integration - Swan (#1517) * fix create_order issue * fix url and better error-handling * basic balances tab * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * fix controller-test * fix singleton testing issues Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 04:47:28 -06:00
)
from cryptoadvance.specter.util.specter_migrator import SpecterMigration
from cryptoadvance.specter.util.migrations.migration_0000 import SpecterMigration_0000
from cryptoadvance.specter.services.service import Service
from cryptoadvance.specterext.devhelp.service import DevhelpService
from cryptoadvance.specterext.electrum.service import ElectrumService
from cryptoadvance.specterext.spectrum.service import SpectrumService
from cryptoadvance.specterext.swan.service import SwanService
Feature: Service integration - Swan (#1517) * fix create_order issue * fix url and better error-handling * basic balances tab * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * fix controller-test * fix singleton testing issues Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 04:47:28 -06:00
def test_get_module_from_class():
assert (
_get_module_from_class(SpecterMigration).__name__
== "cryptoadvance.specter.util.specter_migrator"
)
Bugfix: Final Swan service updates (#1533) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-24 07:47:26 -06:00
assert (
_get_module_from_class(Service).__name__
== "cryptoadvance.specter.services.service"
)
Feature: Service integration - Swan (#1517) * fix create_order issue * fix url and better error-handling * basic balances tab * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * fix controller-test * fix singleton testing issues Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 04:47:28 -06:00
Feature: several things for Spectrum preparation (#1913) * change Node persistence format * Removing the Singleton * mainly refactoring * intermediate commit * fix test * Updated diagram * fix tests * removing simplejsons references * fix tests * remove update, tests working * abstract Node * refining Migration framework: run migrations until they suceed * BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes * clicking redirects to node config if there is no node connection * AbstractNode * BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes * clicking redirects to node config if there is no node connection * handling broken connection when there is no other error superseding (i.e. no wallets) * Abstract Node improvements and issue fixing * improving node_info handling * fix test results, property device_manager in user, bcce in get_rpc in node, improved rpc property in node * typos * provide data_folders for extensions * parametrizing include for node_info * Remove initial_node_contribution refactoring welcome * adding convenience methods * extension data-storage * Tests green * Better failure resistence * Enabling Node settings * error handling * adjust_view_model callback * exception Handling * Shielding core from extension flaws * More consistent logging * Refactoring wallets endpoints * Make wallet_overview extendable * butgifex and cleanup * feedback by Manolis * rename BusinessObject to PersistentObject * fix Error-management and rollback information * Nodes.md corrections * frontend-aspects.md (small) corrections * fix tests and address feedback and errormanagement * fix tests, proper error-handling * Fix test_util_reflection * just some little addons to test_util_reflection * fix cleanup_on_exit * migration fix * remove check, add redirect after saving node * fix test (not that cool but what to do?) * upgrade Flask as Flask-SQLAlchemy needs higher Flask version * Revert "upgrade Flask as Flask-SQLAlchemy needs higher Flask version" This reverts commit bf24120f891f2589bd0fd3ddb3df002323181553. * update bug fixed + node manager added to node test * cleanup external_node Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-10-29 15:54:34 +02:00
def test_get_class():
assert type(get_class("cryptoadvance.specter.device.Device")) == type(Device)
assert get_class("cryptoadvance.specter.node.Node").__name__ == "Node"
# It doesn't make sense to raise SpecterErrors as the error messages aren't meaningful to the user
with pytest.raises(
SpecterInternalException,
match="Could not find cryptoadvance.specter.node.notExisting",
):
get_class("cryptoadvance.specter.node.notExisting")
with pytest.raises(
SpecterInternalException,
match="Could not find cryptoadvance.notExisting.notExisting",
):
get_class("cryptoadvance.notExisting.notExisting")
Feature: Service integration - Swan (#1517) * fix create_order issue * fix url and better error-handling * basic balances tab * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * fix controller-test * fix singleton testing issues Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 04:47:28 -06:00
def test_get_package_dir_for_subclasses_of():
assert get_package_dir_for_subclasses_of(SpecterMigration).endswith(
"cryptoadvance/specter/util/migrations"
)
assert get_package_dir_for_subclasses_of(Service).endswith(
"cryptoadvance/specterext"
Feature: Service integration - Swan (#1517) * fix create_order issue * fix url and better error-handling * basic balances tab * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * fix controller-test * fix singleton testing issues Co-authored-by: Kim Neunert <k9ert@gmx.de> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Kim Neunert <kneunert@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 04:47:28 -06:00
)
Bugfix: Very last fixes for Service swan (#1537) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh * Refactor service_manager and templates where they belong to * Swan - different fronend-links links for dev/prod * include templates and services in sdist * implement dynamic loading but from list in config * No dynamic cwd services in appimages * tidy up Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: kdmukai <kdmukai@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-26 22:11:26 +01:00
def test_get_classlist_from_importlist(caplog):
caplog.set_level(logging.DEBUG)
modulelist = [
"cryptoadvance.specterext.swan.service",
Bugfix: Very last fixes for Service swan (#1537) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh * Refactor service_manager and templates where they belong to * Swan - different fronend-links links for dev/prod * include templates and services in sdist * implement dynamic loading but from list in config * No dynamic cwd services in appimages * tidy up Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: kdmukai <kdmukai@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-26 22:11:26 +01:00
]
classlist = get_classlist_of_type_clazz_from_modulelist(Service, modulelist)
assert len(classlist) == 1 # Happy to remove that at some point
Bugfix: Very last fixes for Service swan (#1537) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh * Refactor service_manager and templates where they belong to * Swan - different fronend-links links for dev/prod * include templates and services in sdist * implement dynamic loading but from list in config * No dynamic cwd services in appimages * tidy up Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: kdmukai <kdmukai@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-26 22:11:26 +01:00
assert SwanService in classlist
classlist = get_classlist_of_type_clazz_from_modulelist(
Device, ["cryptoadvance.specter.devices.bitbox02"]
)
assert len(classlist) == 1
assert BitBox02 in classlist
Bugfix: Very last fixes for Service swan (#1537) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh * Refactor service_manager and templates where they belong to * Swan - different fronend-links links for dev/prod * include templates and services in sdist * implement dynamic loading but from list in config * No dynamic cwd services in appimages * tidy up Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: kdmukai <kdmukai@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-26 22:11:26 +01:00
def test_get_classlist_skips_missing_module(caplog):
"""Missing modules should be skipped with a warning when skip_missing=True.
Regression test for #2496."""
caplog.set_level(logging.WARNING)
modulelist = [
"cryptoadvance.specterext.swan.service",
"cryptoadvance.specterext.nonexistent_extension.service",
"cryptoadvance.specterext.devhelp.service",
]
classlist = get_classlist_of_type_clazz_from_modulelist(
Service, modulelist, skip_missing=True
)
# Should load swan and devhelp, skip the missing one
assert SwanService in classlist
assert DevhelpService in classlist
assert len(classlist) == 2
# Should have logged a warning about the missing module
assert "Skipping module" in caplog.text
assert "nonexistent_extension" in caplog.text
def test_get_classlist_skips_missing_module_empty_list(caplog):
"""If ALL modules are missing, should return empty list, not crash."""
caplog.set_level(logging.WARNING)
modulelist = [
"cryptoadvance.specterext.totally_fake.service",
]
classlist = get_classlist_of_type_clazz_from_modulelist(
Service, modulelist, skip_missing=True
)
assert classlist == []
assert "Skipping module" in caplog.text
def test_get_classlist_raises_on_missing_module_by_default():
"""Without skip_missing, missing modules should still raise (strict mode)."""
modulelist = [
"cryptoadvance.specterext.nonexistent_extension.service",
]
with pytest.raises(ModuleNotFoundError):
get_classlist_of_type_clazz_from_modulelist(Service, modulelist)
repo_root = Path(__file__).parent.parent
xtestdata = repo_root / "tests" / "xtestdata_testextensions"
def test_is_specter_desktop_project():
"""The specter-desktop project detects itself via the name in its own
pyproject.toml. If that name changes (PEP 503 allows "." "-" and "_" to be
used interchangeably), the dev-server dies on startup, see #2526."""
assert is_specter_desktop_project(repo_root)
assert not is_specter_desktop_project(xtestdata / "ext_root_fully_qualified_1")
assert not is_specter_desktop_project(xtestdata)
def test_is_specter_desktop_project_pep503_names(tmp_path):
for name in [
"cryptoadvance.specter",
"cryptoadvance_specter",
"Cryptoadvance-Specter",
]:
(tmp_path / "pyproject.toml").write_text(
f'[project]\nname = "{name}"\nversion = "1.2.3"\n'
)
assert is_specter_desktop_project(tmp_path), f"{name} should be detected"
(tmp_path / "pyproject.toml").write_text(
'[project]\nname = "boatacccorp.tretboot"\n'
)
assert not is_specter_desktop_project(tmp_path)
def test_get_subclasses_for_clazz_in_cwd_in_specter_desktop_project(monkeypatch):
"""No dynamic extension-discovery in the specter-desktop project itself.
Regression test: this used to raise "This should not happen!" when the
project got renamed to cryptoadvance_specter, breaking
`python3 -m cryptoadvance.specter server --config DevelopmentConfig`"""
# the production code takes a shortcut for tests, so pretend we're not testing
monkeypatch.delenv("PYTEST_CURRENT_TEST", raising=False)
assert get_subclasses_for_clazz_in_cwd(Service, cwd=repo_root) == []
def test_get_subclasses_for_clazz_in_cwd(caplog):
caplog.set_level(logging.DEBUG)
classlist: List[type] = get_subclasses_for_clazz_in_cwd(Service, cwd=xtestdata)
# That folder is a container of extension-projects, not an extension-project
# itself, so there is nothing importable in there
assert classlist == []
assert "Detected Extension-style: adhoc" in caplog.text
Bugfix: Very last fixes for Service swan (#1537) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh * Refactor service_manager and templates where they belong to * Swan - different fronend-links links for dev/prod * include templates and services in sdist * implement dynamic loading but from list in config * No dynamic cwd services in appimages * tidy up Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: kdmukai <kdmukai@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-26 22:11:26 +01:00
def test_get_subclasses_for_class(caplog):
caplog.set_level(logging.DEBUG)
Bugfix: Very last fixes for Service swan (#1537) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh * Refactor service_manager and templates where they belong to * Swan - different fronend-links links for dev/prod * include templates and services in sdist * implement dynamic loading but from list in config * No dynamic cwd services in appimages * tidy up Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: kdmukai <kdmukai@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-26 22:11:26 +01:00
classlist = get_subclasses_for_clazz(SpecterMigration)
assert len(classlist) >= 3
Bugfix: Very last fixes for Service swan (#1537) * Feature: Voltoro trading first commit * fix create_order issue * fix url and better error-handling * basic balances tab * Add deposit vaultoro page * activating services * Service management * Improve settings page and default to it if token unset * Fix history tab * Fix trade error handling * Add withdraw * calling specter-cloud for creating vaultoro orders * Improve trade screen and fixes * sidebar fix * black * refactor Service integration * refactor to have Service Classes like manifests * maturity * dynamic initialisation of service-classes and blueprints * fix sidebar_services * migrated templates and static into vaultoro folder * refactor config to manifest * some minor things * swan initial * rename and fix test * adding ServiceApiKeyStorageUserAware * fix * store the access token * directory indirection to shield templates from each others blueprint * first attempts with automatic withdrawals * proper tab highlighting * Interim commit * Update service_apikey_storage.py * Update oauth2_success.jinja * Awaiting refresh_token support * Service logo display on Addresses * Associate addr with a Service * address-data component reorg Separates the presentation html from the data as much as possible. * Services data/icon added to tx History * Now hitting the updated Swan endpoint to save deposit addrs * Simplified injecting Services data into JS * Reducing js calls back to server in tx-data; templatizing utxo in/outs * renaming "reserving" to "associating" an Address with a Service. * rename `manifest.py` files to `service.py`. * rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match. * Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`. * interim commit * Removed tx-table/row/data changes and address-table/row/data Kept only the bare minimum changes required to display the Services icon, plus optimizations. * interim commit * Interim commit * Cleanup commit * Update controller.py * Update services.md * Update services.md * deleted no longer used CustomElement * Adding services docs to mkdocs * Configuration for Services * more clever configuration * fix test * deleted swan_client * Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox. * Better state management if Auth method changes * Cleanup, better user messaging; pulling Service methods out of controller and User * Redirect to services endpoint after setting up authentication. * PR cleanup, bug fixes, test suite updates * Fixed test case problem * First fix for delete API key button. * Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret * Restoring bugfix from @moneymanolis * black * cleanup and black * Make service-decovery in AppImage work * import hashlib, maybe fix cypress * Update service_encrypted_storage.py * further bugfix on update * TODO: remove debugging in client.py before first release * testing env setup markdown * make service-list more resilient * tiny bit more logging in case of issues. * Swan api firewall fix * Restoring lost services-related code in wallets_api.py; bugfix on service_data mismatch * Bugfix on updated completed autowithdrawal addr labels * publish markdown on doc-page * Still awaiting final Swan prod tests * move ServiceManager outside Specter.__init__() * Update config.py * Applying Kim's prop patch * Disabling extension loading from cwd in prod * build-script adjustments for clarity and right order * More comprehensive input validation for the rate limit in the auth settings. * monkey patch rthooks for a successfull MacOS-build * fix build-ci.sh * Refactor service_manager and templates where they belong to * Swan - different fronend-links links for dev/prod * include templates and services in sdist * implement dynamic loading but from list in config * No dynamic cwd services in appimages * tidy up Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: kdmukai <kdmukai@gmail.com> Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-26 22:11:26 +01:00
classlist = get_subclasses_for_clazz(Service)
assert len(classlist) == 5 # Happy to remove that at some point
assert SwanService in classlist
assert ElectrumService in classlist
assert DevhelpService in classlist