Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Apr 26, 2021
1 parent 85fbd91 commit 1b70247
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion x-pack/plugins/cases/common/api/cases/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const ClosureTypeRT = rt.union([rt.literal('close-by-user'), rt.literal('close-b
const CasesConfigureBasicRt = rt.type({
connector: CaseConnectorRt,
closure_type: ClosureTypeRT,
// TODO: should a user be able to update the owner?
owner: rt.string,
});

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/server/authorization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const Operations: Record<ReadOperations | WriteOperations, OperationDetai
name: WriteOperations.UpdateConfiguration,
action: 'update-configuration',
verbs: updateVerbs,
docType: 'case-configuration',
docType: 'case configuration',
savedObjectType: CASE_CONFIGURE_SAVED_OBJECT,
},
[ReadOperations.GetCase]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
CaseConfigureRequestParamsRt,
throwErrors,
CasesConfigurePatch,
excess,
} from '../../../../common/api';
import { RouteDeps } from '../types';
import { wrapError, escapeHatch } from '../utils';
Expand All @@ -31,7 +32,7 @@ export function initPatchCaseConfigure({ router, logger }: RouteDeps) {
async (context, request, response) => {
try {
const params = pipe(
CaseConfigureRequestParamsRt.decode(request.params),
excess(CaseConfigureRequestParamsRt).decode(request.params),
fold(throwErrors(Boom.badRequest), identity)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default ({ getService }: FtrProviderContext): void => {
});
});

it('should not get a case', async () => {
it('should not get a case when the user does not have access to owner', async () => {
const newCase = await createCase(
supertestWithoutAuth,
getPostCaseRequest({ owner: 'securitySolutionFixture' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default ({ getService }: FtrProviderContext): void => {
await actionsRemover.removeAll();
});

// TODO: Decide what to do with no configuration (no owner)
it('should return an empty find body correctly if no configuration is loaded', async () => {
const configuration = await getConfiguration({ supertest });
expect(configuration).to.eql([]);
Expand Down Expand Up @@ -200,7 +199,7 @@ export default ({ getService }: FtrProviderContext): void => {
]) {
it(`User ${scenario.user.username} with role(s) ${scenario.user.roles.join()} and space ${
scenario.space
} - should NOT read a case`, async () => {
} - should NOT read a case configuration`, async () => {
// super user creates a configuration at the appropriate space
await createConfiguration(supertestWithoutAuth, getConfigurationRequest(), 200, {
user: superUser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ export default ({ getService }: FtrProviderContext): void => {
);
});

it('should not allow excess attributes', async () => {
const configuration = await createConfiguration(supertest);
await updateConfiguration(
supertest,
configuration.id,
// @ts-expect-error
{ notExist: 'not-exist', version: configuration.version },
400
);
});

describe('rbac', () => {
it('User: security solution only - should update a configuration', async () => {
const configuration = await createConfiguration(
Expand Down

0 comments on commit 1b70247

Please sign in to comment.