-
-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bf1b78
commit 2363d99
Showing
5 changed files
with
72 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,12 @@ import { | |
} from '../../../test/e2e/helpers/test-helper'; | ||
import getLogger from '../../../test/fixtures/no-logger'; | ||
import type { FeatureSearchQueryParameters } from '../../openapi/spec/feature-search-query-parameters'; | ||
import { DEFAULT_PROJECT, type IUnleashStores } from '../../types'; | ||
import { | ||
CREATE_FEATURE_STRATEGY, | ||
DEFAULT_PROJECT, | ||
type IUnleashStores, | ||
UPDATE_FEATURE_ENVIRONMENT, | ||
} from '../../types'; | ||
import { DEFAULT_ENV } from '../../util'; | ||
|
||
let app: IUnleashTest; | ||
|
@@ -29,7 +34,7 @@ beforeAll(async () => { | |
); | ||
stores = db.stores; | ||
|
||
await app.request | ||
const { body } = await app.request | ||
.post(`/auth/demo/login`) | ||
.send({ | ||
email: '[email protected]', | ||
|
@@ -43,12 +48,30 @@ beforeAll(async () => { | |
|
||
await app.linkProjectToEnvironment('default', 'development'); | ||
|
||
await stores.accessStore.addPermissionsToRole( | ||
body.rootRole, | ||
[ | ||
{ name: UPDATE_FEATURE_ENVIRONMENT }, | ||
{ name: CREATE_FEATURE_STRATEGY }, | ||
], | ||
'development', | ||
); | ||
|
||
await stores.environmentStore.create({ | ||
name: 'production', | ||
type: 'production', | ||
}); | ||
|
||
await app.linkProjectToEnvironment('default', 'production'); | ||
|
||
await stores.accessStore.addPermissionsToRole( | ||
body.rootRole, | ||
[ | ||
{ name: UPDATE_FEATURE_ENVIRONMENT }, | ||
{ name: CREATE_FEATURE_STRATEGY }, | ||
], | ||
'production', | ||
); | ||
}); | ||
|
||
afterAll(async () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/migrations/20241129102205-add-foreign-key-to-role-permissions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
exports.up = function (db, cb) { | ||
db.runSql( | ||
` | ||
UPDATE role_permission SET environment = null where environment = ''; | ||
DELETE FROM role_permission WHERE environment IS NOT NULL AND environment NOT IN (SELECT name FROM environments); | ||
ALTER TABLE role_permission ADD CONSTRAINT fk_role_permission_environment FOREIGN KEY (environment) REFERENCES environments(name) ON DELETE CASCADE; | ||
`, | ||
cb, | ||
); | ||
}; | ||
|
||
exports.down = function (db, cb) { | ||
db.runSql( | ||
` | ||
ALTER TABLE role_permission | ||
DROP CONSTRAINT IF EXISTS fk_role_permission_environment; | ||
`, | ||
cb, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters