feat: 🎸 allow session recording deletion (#2132)
* feat: 🎸 allow session recording deletion
This commit is contained in:
1 parent
4db8b8e1e7
commit
786e6130cd
9 files changed
+136
-4
No files matched your search
@@ -21,6 +21,14 @@ export default class SessionRecordingAbility extends ModelAbility {
|
||||
return !this.model.isUnknown && super.canRead;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only "known" session recording types may be deleted.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get canDelete() {
|
||||
return !this.model.isUnknown && super.canDelete && this.model.isAvailable;
|
||||
}
|
||||
|
||||
get canDownload() {
|
||||
return this.hasAuthorizedAction('download');
|
||||
}
|
||||
|
||||
@@ -798,6 +798,8 @@ function routes() {
|
||||
},
|
||||
);
|
||||
|
||||
this.del('/session-recordings/:id');
|
||||
|
||||
/* Uncomment the following line and the Response import above
|
||||
* Then change the response code to simulate error responses.
|
||||
* this.get('/scopes', () => new Response(505));
|
||||
|
||||
@@ -60,6 +60,7 @@ export default factory.extend({
|
||||
'read',
|
||||
'download',
|
||||
'reapply-storage-policy',
|
||||
'delete',
|
||||
],
|
||||
|
||||
withNonExistingUserAndTarget: trait({
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import {
|
||||
STATE_SESSION_RECORDING_AVAILABLE,
|
||||
STATE_SESSION_RECORDING_STARTED,
|
||||
TYPE_SESSION_RECORDING_SSH,
|
||||
} from 'api/models/session-recording';
|
||||
|
||||
module('Unit | Ability | session-recording', function (hooks) {
|
||||
setupTest(hooks);
|
||||
@@ -49,4 +54,36 @@ module('Unit | Ability | session-recording', function (hooks) {
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('can delete a session with proper authorization and in available state', function (assert) {
|
||||
const recordingNotinAvaialableState = store.createRecord(
|
||||
'session-recording',
|
||||
{
|
||||
authorized_actions: ['delete'],
|
||||
type: TYPE_SESSION_RECORDING_SSH,
|
||||
state: STATE_SESSION_RECORDING_STARTED,
|
||||
},
|
||||
);
|
||||
const recordingInAvailableState = store.createRecord('session-recording', {
|
||||
authorized_actions: ['delete'],
|
||||
type: TYPE_SESSION_RECORDING_SSH,
|
||||
state: STATE_SESSION_RECORDING_AVAILABLE,
|
||||
});
|
||||
assert.false(
|
||||
canService.can('delete session-recording', recordingNotinAvaialableState),
|
||||
);
|
||||
assert.true(
|
||||
canService.can('delete session-recording', recordingInAvailableState),
|
||||
);
|
||||
});
|
||||
|
||||
test('can re-apply Storage policy with proper authorization', function (assert) {
|
||||
const recording = store.createRecord('session', {
|
||||
authorized_actions: ['reapply-storage-policy'],
|
||||
});
|
||||
|
||||
assert.true(
|
||||
canService.can('reapplyStoragePolicy session-recording', recording),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user