1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 09:34:04 +00:00
Commit graph

1164 commits

Author SHA1 Message Date
Samuel Štancl
32a063b834
Laravel 11 support + Docker improvements (#29)
* wip

* bump jobpipeline dependency

* bump pest dependency

* fix composer.json syntax

* minor changes to docker setup

* more docker changes

* compact pest output, remove unnecessary env vars from composer.json

* minor pest tweaks

* mssql fix

* try enabling colors in CI

* try setting --columns=max for pest in CI

* try setting columns using env var instead of --columns in CI

* Revert "try setting columns using env var instead of --columns in CI"

This reverts commit eb3c177aefa97b0a3140d7f0e89c5012a854ff42.

* replace --compact with --no-progress

* try setting a hardcoded columns value in CI

* remove --columns (doesn't work), add back --compact

* try setting COLUMNS to a hardcoded value in CI

* remove alternative env syntax from CI

* fix PrefixCacheBootstrapperTest on L11, skip on L10

* add one more skip() call

* fix validate.yml

* Simplify schema dump, skip dump-related tests in L10

* Rename 'dump' table to 'example'

* Bring schema dump-related tests together, add comments

* Merge schema path-related tests into one, add comments

* Rename dataset parameter

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
2024-02-18 00:18:31 +01:00
Samuel Štancl
d2ab2dacf2
Merge pull request #32 from tenancy-for-laravel/merge-3x-feb2024
Merge 3.x into master
2024-02-11 00:23:32 +01:00
bcf8256ef6 Merge branch 'merge-3x-feb2024' of github.com:tenancy-for-laravel/v4 into merge-3x-feb2024 2024-02-11 00:08:15 +01:00
4b52fed4a0 fix more files broken in automerge 2024-02-11 00:07:38 +01:00
PHP CS Fixer
640305284b Fix code style (php-cs-fixer) 2024-02-10 23:04:12 +00:00
56a6f25dac fix phpstan errors 2024-02-10 23:55:56 +01:00
2eda22772c import Exception 2024-02-10 23:51:04 +01:00
a7368264c2 remove duplicate method from automerge 2024-02-10 23:40:04 +01:00
99706f95ef fix ci.yml 2024-02-10 23:37:46 +01:00
7c29764d81 Merge remote-tracking branch 'origin/3.x' 2024-02-10 23:34:47 +01:00
fe4ee6336f Merge remote-tracking branch 'origin/merge-3.x' 2024-02-10 23:02:12 +01:00
Samuel Štancl
05e2167e9b
Merge pull request #31 from tenancy-for-laravel/merge-public-repo-master
Merge archtechx/tenancy master into v4/master
2024-02-10 22:01:32 +01:00
a430b1de29 Merge remote-tracking branch 'origin/master' into merge-public-repo-master 2024-02-10 21:55:54 +01:00
lukinovec
222bbe4c02
Final filesystem-related changes (#25)
* Change %tenant_id% to %tenant%

* ID -> key

---------

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2024-02-10 19:13:02 +01:00
Samuel Štancl
6784685054
Resource syncing rework (#30)
* Add &Model to docblock

* Fix code style (php-cs-fixer)

* Only delete synced resource if the central resource shouldSync

* Add central resource detached event and listener

* Add SyncedTenant interface

* Use the event & listener in the test file

* Add getGlobalIdentifierKey(Name) to TenantMorphPivot

* Refactor TriggerSyncingEvents

* Fix code style (php-cs-fixer)

* Test queueing the detaching listener

* Move finding the central resource into the event, naming changes

* Fix code style (php-cs-fixer)

* Simplify listener code

* Refactor detaching logic

* Create tenant resource after attaching central to tenant, test queueing related listener

* Delete dd()

* Fix code style (php-cs-fixer)

* Move triggerAttachEvent from SyncMaster

* Update attach event-related code

* Move findResource from SyncedTenant to the pivot trait

* Add annotation

* Update annotation

* Simplify getAttributesForCreation in CreateTenantResourceFromSyncMaster

* Update naming

* Add tenant trait for attaching/detaching resources

* Update test names

* Move creation attribute parsing method to trait

* Rename variable

* Fix code style (php-cs-fixer)

* Delete complete to-do

* Delete event comment

* Rename event property

* Find tenant resource in detach listener

* Use global ID key of tenant resource in cascade deletes listener

* Use global ID key name of the central resource while creating/deleting tenant resources

* Add getSyncedCreationAttributes example in the annotation

* Fix inconsistencies in SyncedTenant methods

* Improve annotation

* Don't return the query in `$scopeGetModelQuery`

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Fix code style (php-cs-fixer)

* Update scoping getModel query

* Only use detach event instead of using both detach and delete events, refactor code

* Test that detaching tenant from a central resource doesn't affect other tenants

* Delete extra imports

* Fix code style (php-cs-fixer)

* Add PivotWithRelation, test attaching/detaching resources without polymorphic relations

* Refactor TriggerSyncingEvents to work with non-polymorphic relations too

* Fix code style (php-cs-fixer)

* Rename synced resource changed event, fix tests

* Enforce passing Tenant&Model to attach/detach events

* Prevent firing saved event automatically in CreateTenantResource

* Improve TriggerSyncingEvents trait

* Delete unused import

* Make TriggerSyncingEvents methods non-static, improve annotations

* Pass saved model to event

* Move attach/detach queueing tests to ResourceSyncingTest, pass models instead of IDs to attach/detach

* Move events to ResourceSyncing\Events

* Fix code style (php-cs-fixer)

* Use SerializesModels in queueable listeners instead of events

* Delete redundant $shouldQueue setting

* Rename listener, test cascade deletes from both sides of many-to-many

* Move creation attributes-related code to a separate test file, improve comments (wip)

* Improve comments, fix variable name capitalization

* Delete tracing comma

* Extract duplicate code into a trait

* Don't accept nullable tenant in SyncMasterDeleted

* Fix annotation

* Fix code style (php-cs-fixer)

* Update annotation

* Fix PHPStan error

* Fix annotation

* Update comments and test naming

* Move triggerDeleteEvent to CascadeDeletes interface

* Rename test file

* Import TenantPivot in Tenant class (tests/Etc)

* Add central resource not available in pivot exception

* Rename SaveSyncedResource to UpdateOrCreateSyncedResource

* Add new events and listeners to TSP stub

* Improve comments and naming

* Only keep SerializesModels in classes that utilize it

* Use tenant->run()

* Import events in stub

* Move RS listeners to separate namespace, use `Event/`Listener/` in stub for consistency

* Fix code style (php-cs-fixer)

* Fix namespace changes

* Use cursor instead of get

* Update src/ResourceSyncing/ParsesCreationAttributes.php

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Update naming, structure (discussed on Discord)

* Update uses in in test file

* remove double ;;

* Add comments

* Test if static properties work fine with queueable listeners

* Update $shouldQuery test

* Update creation attributes

* Work on updating the tests

* Make synced attributes configurable using static properties

* Update resource syncing tests

* Get rid of mixed attribute classes

* Get rid of TenantUserWIthCreationAttributes

* Fix imports

* Get rid of the conditionally synced classes, improve tests

* Simplify resource creation tests (only test the more complex cases instead of each case - if the complex case works, the simpler cases work too)

* Clean up ResourceSyncingTest (mostly duplicate tests that were already in AutomaticResourceCreationTest)

* Simplify class naming in polymorhpic tests

* Move automatic resource creation tests to ResourceSyncingTest

* Test that the sync event doesn't get triggered excessively

* Only trigger the sync event if the synced attributes were changed or if the resource was recently created

* Update synced attribute instead of unsynced in test

* Fix sync event test

* Update static property redefining test

* Use getGlobalIdentifierKeyName() instead of hardcoding the key name

* Delete static properties from the ResourceSyncing trait

* Reuse user classes in polymorphic tests

* Update tests/ResourceSyncingTest.php

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Use the default tenants() method in central user, override the default in ResourceSyncingTest

* Use BelongsToMany as tenants() return type

* Fix code style (php-cs-fixer)

* Delete extra static property from trait

* Delete duplicate events/listeners from TSP stub

* Delete weird expectation,  use $model->trashed()

* Change ResourceUser to TenantUser

* Add defaults for getGlobalIdentifierKey(Name)

* Use singular tenant in DeleteResourceInTenants name

* Rename getSyncedCreationAttributes to getCreationAttributes

* Fix comma position in comment

* minor fixes in traits and interfaces

* Fix code style (php-cs-fixer)

* Correct comment

* Use $tenant->run()

* Update scopeGetModelQuery annotation

* Use static property for testing shouldSync

* Improve test

* Get rid of datasets

* Add trashed assertions

* Always merge synced attributes with the creation attributes during parsing

* Update creation attributes in test's beforeEach

* Use only the necessary creation attributes (no need to include the synced attributes because they get merged automatically)

* Rename ResourceTenant to MorphTenant

* Add TriggerSyncingEvents docblock

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Add force deletes test

* Fix code style (php-cs-fixer)

* Delete pivot if it can't access the resource class

* Make parseCreationAttributes more readable

* Comment out setting $scopeGetModelQuery in the stub

* Add @var annotations to bootTriggerSyncingEvents

* Fix attach()/detach() exception test

* Interrupt creation of broken pivots instead of deleting the pivots at a later point

* Add more comments

* Update CreateTenantResource comment

* Assert that forceDelete() doesn't affect other tenant resources

* Rename test

* Correct with() array formatting

* Expand test with soft deletes

* Merge SyncedResourceSaved tests

* Improve naming, comments and minor details in the assertions

* Move test

* Fix failing test

* Delete duplicate test

* Minor test improvement

* Delete duplicate test

* Improve old test

* Minor test improvement

* Improve event test

* Improve tests (naming, code, comments)

* Delete extra test, add comments to the larger test

* Refactor central -> tenant attach() test

* Apply changes from central -> tenant attach() test on tenant -> central test

* Fix assertions in central -> tenant

* Correct comment and assertion

* Refactor tenant -> central attach() test

* Fix inconsistency

* Delete unused import

* Add comments

* Update polymorphic test names

* Rename polymorphic tests

* Update listener test name

* Delete redundant tenant ID assignments

* Improve test names

* Move polymorphic tests to ResourceSyncingTest

* Mention alternative solutions in CentralResourceNotAvailableInPivotException

* Add comments

* Update test comments

* minor changes to tests + review comments

* Delete extra tests, update comments

* Remove unneeded part of test

* Fix comment

* Improve comments

* Add test for companies() realationship accessibility

* Update test name

* Complete to-do, add comment

* Improve naming and comments (resolve some priority reviews)

* Move test

* Comment, resolve to-dos

* Add low-level pivot assertions

* Restore trashed resources if the central resource got restored, try improving tests

* Fix code style (php-cs-fixer)

* Dekete redundnat unsynced comments

* Add to-do, test WIP

* Fix restoring logic

* Update todo

* Add todo to fix phpdoc

* Fix code style (php-cs-fixer)

* PHPStan error fix wip

* Fix PHPStan error

* Add regression test

* Delete unused trait

* Add and test restoring WIP

* Fix code style (php-cs-fixer)

* Add to-do

* Delete comment from test

* Focus on restoring in the restore test

* Improve maming

* Fix stub

* Delete redundant part of test

* Delete incorrect test leftover

* Add triggerRestoredEvent

* Fix restore test

* Correct tests and restore(() logic

* Fix code style (php-cs-fixer)

* Check if SoftDeletes are used before firing SyncMasterRestored

* Fix comment

* Revert restore action changes (phpstan errors)

* Delete CascadeDeletes interface

* Remove CascadeDeletes from most of the tests

* Fix code style (php-cs-fixer)

* Rename tests

* Fix restoring + tests WIP

* Fix restoring

* Fix restoring tests

* Fix code style (php-cs-fixer)

* Test that detaching force deletes the tenant resources

* Implement cacscade force deleting

* Delete redundant changes

* Fix typo

* Fix SyncMaster

* Improve test

* Add force deleting logic back and fix tests

* Improve comment

* Delete extra assertion

* Improve restoring test

* Simplify assertion

* Delete redundant query scoping from test

* Test restore listener queueing

* use strict in_array() checks

* fix phpstan errors

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2024-02-10 19:08:37 +01:00
lukinovec
aa1437fb5e
Resolve misc to-dos (#26)
* Resolve delete tenant storage todo

* Delete outdated todo (resolved in #25)

* Delete resource syncing todo (resolved in #11)

* Make it clear that getArgsForTenant() is used during cache invalidation

* Delete redundant __call() and __callStatic() annotations

* Fix code style (php-cs-fixer)

* Revert %tenant_id% to-do removal

* Test all cached resolvers instead of just the domain one

* Make docblock more concise, delete renaming to-do (the name seems fine)

* Fix method in tests

* If route is the only resolver arg, use the tenant as the cache key instead of encoded route instance

* Resolve to-do

* make docblock more clear

* Add comments to getResolverArgument()

* Rename $id to $tenantKey

* Fix code style (php-cs-fixer)

* Add regression test for forgetting tenant parameters of cached tenants

* Forget route parameter when tenant gets resolved

* Add parameter type

* Simplify getCacheKey()

* Resolvers wip

* Resolvers wip

* Fix code style (php-cs-fixer)

* Bring back the route instance check to getCacheKey, fix test

* add todo

* add assertion

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2024-02-10 18:38:05 +01:00
lukinovec
80b1183fbf
Make clone action prefix already prefixed routes correctly (#28)
* Add regression test

* Complete prefixing test

* Delete redundant line from test

* Refactore clone action, fix prefixing logic

* Improve test name

* Improve URI string manipulation

* Refactor createNewRoute()

* Fix code style (php-cs-fixer)

* Fix PHPStan error

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2024-02-10 18:19:20 +01:00
8db27a358e Forget tenant parameter when a tenant is resolved from cache in PathTenantResolver (fix #1174) 2024-01-27 22:55:59 +01:00
chillbram
5fe8825f13
Make universal routes work for controller middleware (#1151)
* Make universal routes work for controller middleware

* add a fallback

---------

Co-authored-by: chillbram <7299762+chillbram@users.noreply.github.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2024-01-25 22:34:47 +01:00
lukinovec
c312156c18
Give universal flag highest priority (#27)
* Give universal flag the highest priority (wip)

* Stop forgetting tenant parameter when route-level path ID is used

* Fix PHPStan errors

* Simplify annotation

* Fix comment

* Correct annotations

* Improve requestHasTenant comment

* Make cloning logic only clone universal routes, delete the universal flag from the new (tenant) route

* Delete APP_DEBUG

* make if condition easier to read

* Update DealsWithRouteContexts.php

* Fix test

* Fix code style (php-cs-fixer)

* Move tests

* Delete incorrectly committed file

* Cloning routes update wip

* Route cloning rework WIP

* Add todo to clone routes

* Fix code style (php-cs-fixer)

* Route cloning fix WIP

* Set CloneRoutesAsTenant::$tenantMiddleware to ID MW

* Revert CloneRoutesAsTenant::$tenantMiddleware-related changes

* Simplify requestHasTenant

* Add and test 'ckone' flag

* Delete setting $skippedRoutes from CloneRoutesAsTenant

* Fix code style (php-cs-fixer)

* make config key used for testing distinct from normal tenancy config keys

* Update src/Actions/CloneRoutesAsTenant.php

* Move 'path identification types' dataset to CloneActionTest

---------

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2024-01-25 15:27:17 +01:00
d268a06f5d tests: assert that tenants:run runs only for the specified tenants 2024-01-18 14:30:40 +01:00
070828a81e add missing ::class 2024-01-11 21:24:28 +01:00
lukinovec
cf3d06c8ec
Add permission-controlled SqlSrv database manager (#17)
* Add permission controleld MSSQL DB manager

* Fix code style (php-cs-fixer)

* Fix manager

* Don't change databases when creating MSSQL user

* Test permission controlled MSSQL DB manager

* Fix code style (php-cs-fixer)

* Delete redundant config resetting in tests

* Grant user permissions insteead of making the user the database owner

* Test that user gets created in the tenant DB

* Test that the correct permissions are granted to the DB users

* Fix code style (php-cs-fixer)

* Update config comment

* Fix typo

* Add perm controlled sqlsr db manager to test dataset

* Close all connections before deleting MSSQL DBs

* Fix code style (php-cs-fixer)

* Add explanation to deleteDatabase()

* Update tests/DatabaseUsersTest.php

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Fix code style (php-cs-fixer)

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2024-01-08 04:07:43 +01:00
lukinovec
9e4f33e5c5
Identify tenants by the "Origin" header (#21)
* Add origin ID MW

* Test origin ID MW

* Test origin ID MW with early identification

* Fix code style (php-cs-fixer)

* Fix PHPStan errors

* Add getDomain() to domain ID MW, simplify origin ID MW

* Fix code style (php-cs-fixer)

* Rename InitializeTenancyByOrigin to InitializeTenancyByOriginHeader

* Add onFail test

* Stop throwing the exception in getDomain()

* FIx merge

* Improve origin identification test file

* Clean up test

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2024-01-08 00:29:01 +01:00
lukinovec
df9324b92f
Stop bypassing tenancy initializition when domain is central in domain ID MW (#24)
* Stop bypassing tenancy initialization when host is central domain in domain ID MW

* Delete dataset for testing global domain ID MW + route-level prevent access MW

* Provide ID MW statically in TenantAssetController

* Fix code style (php-cs-fixer)

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2024-01-03 23:35:49 +01:00
Samuel Štancl
00a00a2aff
Pass BroadcastManager to override closures (#23)
* pass BroadcastManager to override closures

* Improve the broadcaster override syntax in the bootstrapper test

* remove unnecessary return

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
2023-12-20 12:23:37 +01:00
lukinovec
d9b63cdf59
Stop setting $prefixRouteNames to true in path ID MW (#22)
* Stop setting $prefixRouteNames in path ID MW

* Fix code style (php-cs-fixer)

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2023-12-19 17:44:06 +01:00
lukinovec
ea5a7463b8
Allow mapping nested tenant properties to mail config (#20)
* Use data_get() to allow mapping nested tenant attributes to mail config

* Fix code style (php-cs-fixer)

* Test the data_get() change

* Improve code, add info to docblock

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2023-12-18 12:42:03 +01:00
lukinovec
ca400b51d2 Fix global/central channel terminology 2023-12-13 19:11:18 +01:00
Samuel Štancl
6c60a834d5
update larastan include 2023-12-12 11:06:43 +01:00
Samuel Štancl
1acdd1bdb6
remove --xdebug from phpstan job 2023-12-12 11:03:53 +01:00
a5800452ac update larastan dependency 2023-12-12 10:53:23 +01:00
lukinovec
e4df597d81
Make providing identification middleware statically to controllers work (#18)
* Test identification with universal flag with statically provided MW

* Include statically provided controller MW in `tenancy()->getRouteMiddleware()`

* Fix code style (php-cs-fixer)

* Fix PHPStan error

* Test path ID MW and route cloning with statically provided MW

* Create validate.yml

* set continue-on-error to true

* change continue-on-error to fail-fast

* add job name and use if: always()

* update todo

* Update path identification and Fortify integration-related logic (#13)

* Add commented UrlBinding + FortifyRouteTenancy bootstrappers to the config

* Improve FortifyRoute bootstrapper docblock

* Rename bootstrappers

* Complete renaming

* Pass defaults of the original URL generator to the new one

* Fix URL generator-related test (query string id test WIP)

* Fix code style (php-cs-fixer)

* Make Fortify bootstrapper not depend on the UrlGenerator bootstrapper, update comments

* Fix testing UrlGenerator bootstrapper

* Update TenancyUrlGenerator annotations

* Pass tenant parameter manually in Fortify bootstrapper

* Properly test TenancyUrlGenerator functionality

* Get rid of query string in Fortify bootstrapper

* Fix code style (php-cs-fixer)

* Delete outdated comment

* Improve comment

* Improve before/afterEach

* Encourage passing parameters using TenancyUrlGenerator instead of URL::defaults()

* Delete rest of defaulting logic

* Fix code style (php-cs-fixer)

* Delete test group

* Update ForgetTenantParameter docblock

* Update passTenantParameterToRoutes annotation

* Complete todo in test

* Improve test

* Update comment

* Improve comment

* Add keepQueryParameters bool to Fortify bootstrapper

* Test keepQueryParameters

* minor docblock update

* minor docblock changes

* Delete extra import

* Update src/Overrides/TenancyUrlGenerator.php

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Improve comment

* Rename test

* Update bypass parameter-related test comments

* Fix merge

* Rename $keepQueryParameters

* Add docblock

* Add comment

* Refactor Fortify bootstrapper

* Fix code style (php-cs-fixer)

* Fix comment

* Skip Fortify bootstrapper test

* minor code improvements

* Improve fortify bootstrapper test

* Add Fortify bootstrapper annotation, improve code

* Fix code style (php-cs-fixer)

* Add commenet

* Complete resource syncing todo (cleanup not needed)

* Delete incorrect namespace

* Complete route context trait name todo

* Fix code style (php-cs-fixer)

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Include statically provided controller MW in `tenancy()->getRouteMiddleware()`

* Fix code style (php-cs-fixer)

* Improve PHPStan error fix

* Include statically provided controller MW in `tenancy()->getRouteMiddleware()`

* Fix PHPStan error

* Fix code style (php-cs-fixer)

* Include statically provided controller MW in `tenancy()->getRouteMiddleware()`

* Fix code style (php-cs-fixer)

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-12-01 09:38:43 +01:00
lukinovec
4953c69fd8
Update path identification and Fortify integration-related logic (#13)
* Add commented UrlBinding + FortifyRouteTenancy bootstrappers to the config

* Improve FortifyRoute bootstrapper docblock

* Rename bootstrappers

* Complete renaming

* Pass defaults of the original URL generator to the new one

* Fix URL generator-related test (query string id test WIP)

* Fix code style (php-cs-fixer)

* Make Fortify bootstrapper not depend on the UrlGenerator bootstrapper, update comments

* Fix testing UrlGenerator bootstrapper

* Update TenancyUrlGenerator annotations

* Pass tenant parameter manually in Fortify bootstrapper

* Properly test TenancyUrlGenerator functionality

* Get rid of query string in Fortify bootstrapper

* Fix code style (php-cs-fixer)

* Delete outdated comment

* Improve comment

* Improve before/afterEach

* Encourage passing parameters using TenancyUrlGenerator instead of URL::defaults()

* Delete rest of defaulting logic

* Fix code style (php-cs-fixer)

* Delete test group

* Update ForgetTenantParameter docblock

* Update passTenantParameterToRoutes annotation

* Complete todo in test

* Improve test

* Update comment

* Improve comment

* Add keepQueryParameters bool to Fortify bootstrapper

* Test keepQueryParameters

* minor docblock update

* minor docblock changes

* Delete extra import

* Update src/Overrides/TenancyUrlGenerator.php

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Improve comment

* Rename test

* Update bypass parameter-related test comments

* Fix merge

* Rename $keepQueryParameters

* Add docblock

* Add comment

* Refactor Fortify bootstrapper

* Fix code style (php-cs-fixer)

* Fix comment

* Skip Fortify bootstrapper test

* minor code improvements

* Improve fortify bootstrapper test

* Add Fortify bootstrapper annotation, improve code

* Fix code style (php-cs-fixer)

* Add commenet

* Complete resource syncing todo (cleanup not needed)

* Delete incorrect namespace

* Complete route context trait name todo

* Fix code style (php-cs-fixer)

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-11-26 21:08:41 +01:00
Massimo Simonini
0b248f937d
Add step option to migrate-fresh command (#1164) 2023-11-21 02:25:32 +01:00
Samuel Štancl
c043661318
update todo 2023-11-21 02:11:33 +01:00
Samuel Štancl
c6e6964e24
add job name and use if: always() 2023-11-21 02:10:35 +01:00
Samuel Štancl
ce1585ed71
change continue-on-error to fail-fast 2023-11-21 02:07:33 +01:00
Samuel Štancl
d182df4458
set continue-on-error to true 2023-11-21 02:03:00 +01:00
Samuel Štancl
9512886306
Create validate.yml 2023-11-21 01:59:36 +01:00
lukinovec
8b0bdd42ed Make getCustomColumns() static in SingleDomainTenant 2023-11-09 09:35:06 +01:00
lukinovec
e25e7b7961
Single-domain tenants (#16)
* Add SingleDomainTenant

* Add logic for single domain tenants

* Test that the single domain approach works (wip)

* Fix code style (php-cs-fixer)

* Simplify SubdomainTest tests

* Add single domain tenant conditions to DomainTenantResolver

* Test single domain tenants in resolver test

* Fix test name typo

* Improve runUsingBothDomainApproaches()

* Delete extra tenancy()->end()

* Test early identification with both domain approaches

* Test that things work with both domain approaches in the rest of the tests

* Fix falsely passing test

* Fix PHPStan errors

* Change SingleDomainTenant to a contract, add SingleDomainTenant test model

* Fix TenantList domainsCLI()

* Improve setCurrentDomain() check

* Fix code style (php-cs-fixer)

* Add annotation

* Revert getCustomColumns() change

* Add comments

* Use the domain returned by the closure in runUsingBoth..()

* Delete `migrate` from test

* Improve test names

* Use variable instead of repeating the same string multiple times

* Update comment

* Add comment

* Clean up PreventAccess test

* Don't assign domain to a single-use variable

* Update comments

* Uncomment datasets

* Add todo

* Fix user impersonation test

* Don't specify tenant key when creating tenant in runUsingBoth..()

* Improve universal route test

* Improve `runUsingBothDomainApproaches()`

* Add tests specific to single domain tenants

* Get rid of the runUsingBothDomainApproaches method

* Add test file specific for the single domain tenant feature

* Rename test

* Make getCustomColumns() function static

* Positiopn datasets differently

* Fix early id test

* Add prevent MW to route MW in test

* Fix single domain tenant tests

* Delete SingleDomainTenantTest (CI testing)

* Add the test file back

* TUrn APP_DEBUG on temporarily

* Turn debug off

* Try creating tenant with non-unique domain (CI testing)

* dd duplicate tenant records

* Revert testing change

* Make SingleDomainTenant not extend base tenant (VirtualColumn issues)

* Fix early id test

* add todo

* Use dev-master stancl/virtualcolumn

* Make SingleDomainTenant extend the tenant base model

* remove todo

* Clean up EarlyIdentificationTest changes

* Finish test file cleanup

* Fix test

* improve test

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-11-08 11:38:26 +01:00
lukinovec
c34952f328
Add broadcasting channel prefixing bootstrapper (#12)
* Rename old broadcast bootstrapper, add new one

* Add broadcast tenancy bootstrapper + tests

* Fix code style (php-cs-fixer)

* Fix prefixing

* Work on th bootstrapper's tests (wip – problem with events)

* Fix bootstrapper

* Test that auth closures of channels work correctly

* Fix bootstrapper

* Fix code style (php-cs-fixer)

* Delete channel cloning bootstrapper

* Add bootstrapper that prefixes broadcastOn channels under the hood

* Add broadcast channel registering helpers

* Update prefixing tests (WIP)

* Fix code style (php-cs-fixer)

* Improve comment

* Fix code style (php-cs-fixer)

* Allow customization of Pusher/Ably broadcaster extension

* Fix code style (php-cs-fixer)

* Implement prefix bootstrapper logic, test channel prefixing using a closure

* Work on the prefixing bootstrapper and tests

* Fix code style (php-cs-fixer)

* Add optional $options param to broadcasting helpers

* Test broadcasting helpers

* Fix code style (php-cs-fixer)

* Broadcasting channel prefixing + testing progress

* Improve helper methods

* Fix and improve test

* Fix extending in bootstrap()

* Fix code style (php-cs-fixer)

* Add docblocks, name things more accurately

* Fix code style (php-cs-fixer)

* Delete redundant method from testing broadcaster

* Test Pusher channel prefixing (probabaly redundant?)

* Test if channels get prefixed correctly when switching tenants

* Work with the current broadcast manager instead of overriding it

* Give the original channels to the overriden broadcasters

* Fix code style (php-cs-fixer)

* Simplify channel prefix bootstrapper

* Fix code style (php-cs-fixer)

* Fix comment

* Fix test

* Delete annotation

* Delete unused classes from test

* Delete outdated test

* Move broadcasting bootstrapper test to BootstrapperTest

* Improve bootstrapper test, delete unused event

* Add annotations to the bootstrapper

* Fix code style (php-cs-fixer)

* Improve wording

* Improve comment

* Update src/Bootstrappers/BroadcastChannelPrefixBootstrapper.php

* Apply suggestions from code review

* Optionally skip prefixing of specific channels

* Add and test central channel helper, update formatChannels overrides and tests

* Fix code style (php-cs-fixer)

* minor fixes

* Improve annotation

* Use "global__" prefix instead of "central__", add comments

* Correct tests

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-11-06 22:09:01 +01:00
lukinovec
b503dbf33d
Fix rollback command (#14)
* Add and use setParameterDefaults()

* Correct rollback test

* Check ignored parameters instead of directly checking the command's options

* Delete --path setting from the test

* Revert test changes

* Delete new lines
2023-10-16 01:50:59 +02:00
lukinovec
ab240fb675
Correct variable name (#15) 2023-10-12 22:45:52 +02:00
Samuel Štancl
85c7465aca remove unnecessary import 2023-09-02 03:20:42 +02:00
Samuel Štancl
caf2267a08 reimplement TenantAssetsController::validatePath() (fixes #1143) 2023-09-02 03:19:37 +02:00
lukinovec
8d38f42cd0
Correct asset helpers, make asset helpers work with path identification (#6)
* Make asset_helper_tenancy false by default

* Make tenant_asset() respect ASSET_URL

* Set asset helper tenancy to true in tests where needed

* If the `asset_helper_tenancy` key is missing, default to false in filesystem bootstrapper

* Make temporary clone action changes

* Make tenancy asset route universal

* Make the asset controller's asset method behave differently if path ID MW is the default

* Test that asset helper works with path identification

* Fix code style (php-cs-fixer)

* Delete path traversal attack prevention

* Fix code style (php-cs-fixer)

* Skip cloning of stancl.tenancy.asset route in some tests

* Fix code style (php-cs-fixer)

* Clone asset route in TSP stub

* Add cloning only the passed route

* Clone asset route in tenant asset test beforeEach

* Skip asset route cloning by default

* Fix typo

* Change public method back to protected

* Remove cloning of specific routes, skip cloning routes flagged as tenant

* Delete constructor from asset controiler, change asset method to invoke

* Update asset route registration, add prefixed asest route for path identification

* Use default middleware from config instead of `tenancy()->defaultMiddleware()`

* Delete old code from TSP stub

* Revert TSP stub change

* Revert FilesystemTenancyBootstrapper changes

* Suffix asset url in tenant_asset()

* Simplify `tenant_asset()`

* Ensure the base asset url is always suffixed with '/'

* remove unnecessary ?? false

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-08-31 15:44:26 +02:00
lukinovec
f7d9f02fd4
Improve route cloning action (#8)
* Allow cloning routes when only kernel identification is used, explicitly enable specific cloning modes

* Explicitly enable needed clone modes in tests, use "clone" instead of "reregister"

* Fix code style (php-cs-fixer)

* Use  "cloning" instead of "re-registration" in UniversalRouteTest

* Only clone routes using path identification

* Revert clone mode changes

* Fix code style (php-cs-fixer)

* Update comment

* Skip cloning 'stancl.tenancy.asset' by default

* Decide which routes should get cloned in the filtering step, improve method organization

* Return `RouteMode::UNIVERSAL` in getMiddlewareContext if route is universal

* Give universal route the path ID MW so that it gets cloned

* Fix code style (php-cs-fixer)

* Simplify UsableWithEarlyIdentification code

* Handle universal route mode in ForgetTenantParameter

* Fix code style (php-cs-fixer)

* Rename getMiddlewareContext to getRouteMode

* Append '/' to the route prefix

* Rename variable

* Wrap part of condition in parentheses

* Refresh name lookups after cloning routes

* Test giving tenant flag to cloned routes

* Add routeIsUniversal method

* Correct ForgetTenantParameter condition

* Improve tenant flag giving logic

* Improve test name

* Delete leftover testing code

* Put part of condition into `()`

* Improve CloneRoutesAsTenant code + comments

* Extract route mode-related code into methods, refactor and improve code

* Improve ForgetTenantParameter, test tenant parameter removing in universal routes

* Fix code style (php-cs-fixer)

* Fix test

* Simplify adding tenant flag

* Don't skip stancl.tenancy.asset route cloning

* clean up comment

* fix in_array() argument

* Fix code style (php-cs-fixer)

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-08-28 13:17:17 +02:00
lukinovec
4d4639450e
Use randomly generated tenant key instead of 'acme' in failing test (#10) 2023-08-25 17:01:47 +02:00