Skip to content

Commit

Permalink
N21-1587 protected custom parameter (#4658)
Browse files Browse the repository at this point in the history
* extend ctl - customParameter model with isProtected
* update seed data (external tools)
* migration script
---------

Co-authored-by: Igor Richter <[email protected]>
  • Loading branch information
MBergCap and IgorCapCoder authored Dec 22, 2023
1 parent 7e1ab29 commit a13a017
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class CustomParameter {

isOptional: boolean;

isProtected: boolean;

constructor(props: CustomParameter) {
this.name = props.name;
this.displayName = props.displayName;
Expand All @@ -32,5 +34,6 @@ export class CustomParameter {
this.regex = props.regex;
this.regexComment = props.regexComment;
this.isOptional = props.isOptional;
this.isProtected = props.isProtected;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('ExternalToolEntity', () => {
regex: 'mockRegex',
regexComment: 'mockComment',
isOptional: false,
isProtected: false,
});
const externalToolEntity: ExternalToolEntity = externalToolEntityFactory.buildWithId({
name: 'toolName',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ describe('ToolConfigurationController (API)', () => {
name: contextParameter.name,
displayName: contextParameter.displayName,
isOptional: contextParameter.isOptional,
isProtected: contextParameter.isProtected,
defaultValue: contextParameter.default,
description: contextParameter.description,
regex: contextParameter.regex,
Expand Down Expand Up @@ -361,6 +362,7 @@ describe('ToolConfigurationController (API)', () => {
name: schoolParameter.name,
displayName: schoolParameter.displayName,
isOptional: schoolParameter.isOptional,
isProtected: schoolParameter.isProtected,
defaultValue: schoolParameter.default,
description: schoolParameter.description,
regex: schoolParameter.regex,
Expand Down Expand Up @@ -489,6 +491,7 @@ describe('ToolConfigurationController (API)', () => {
name: schoolParameter.name,
displayName: schoolParameter.displayName,
isOptional: schoolParameter.isOptional,
isProtected: schoolParameter.isProtected,
defaultValue: schoolParameter.default,
description: schoolParameter.description,
regex: schoolParameter.regex,
Expand Down Expand Up @@ -644,6 +647,7 @@ describe('ToolConfigurationController (API)', () => {
name: contextParameter.name,
displayName: contextParameter.displayName,
isOptional: contextParameter.isOptional,
isProtected: contextParameter.isProtected,
defaultValue: contextParameter.default,
description: contextParameter.description,
regex: contextParameter.regex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('ToolController (API)', () => {
displayName: 'User Friendly Name',
defaultValue: 'abc',
isOptional: false,
isProtected: false,
type: CustomParameterTypeParams.STRING,
regex: 'abc',
regexComment: 'Regex accepts "abc" as value.',
Expand Down Expand Up @@ -137,6 +138,7 @@ describe('ToolController (API)', () => {
displayName: 'User Friendly Name',
defaultValue: 'abc',
isOptional: false,
isProtected: false,
type: CustomParameterTypeParams.STRING,
regex: 'abc',
regexComment: 'Regex accepts "abc" as value.',
Expand Down Expand Up @@ -367,6 +369,7 @@ describe('ToolController (API)', () => {
displayName: 'User Friendly Name',
defaultValue: 'abc',
isOptional: false,
isProtected: false,
type: CustomParameterTypeParams.STRING,
regex: 'abc',
regexComment: 'Regex accepts "abc" as value.',
Expand Down Expand Up @@ -433,6 +436,7 @@ describe('ToolController (API)', () => {
displayName: 'User Friendly Name',
defaultValue: 'abc',
isOptional: false,
isProtected: false,
type: CustomParameterTypeParams.STRING,
regex: 'abc',
regexComment: 'Regex accepts "abc" as value.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ export class CustomParameterPostParams {
@IsBoolean()
@ApiProperty()
isOptional!: boolean;

@IsBoolean()
@ApiProperty()
isProtected!: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class CustomParameterResponse {
@ApiProperty()
isOptional: boolean;

@ApiProperty()
isProtected: boolean;

constructor(props: CustomParameterResponse) {
this.name = props.name;
this.displayName = props.displayName;
Expand All @@ -47,5 +50,6 @@ export class CustomParameterResponse {
this.regex = props.regex;
this.regexComment = props.regexComment;
this.isOptional = props.isOptional;
this.isProtected = props.isProtected;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export class CustomParameterEntity {
@Property()
isOptional: boolean;

@Property({ default: false })
isProtected: boolean;

constructor(props: CustomParameterEntity) {
this.name = props.name;
this.displayName = props.displayName;
Expand All @@ -44,5 +47,6 @@ export class CustomParameterEntity {
this.regex = props.regex;
this.regexComment = props.regexComment;
this.isOptional = props.isOptional;
this.isProtected = props.isProtected;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('ExternalToolEntity', () => {
regex: 'mockRegex',
regexComment: 'mockComment',
isOptional: false,
isProtected: false,
});
const externalToolEntity: ExternalToolEntity = new ExternalToolEntity({
name: 'toolName',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe('ExternalToolRequestMapper', () => {
customParameterPostParams.regex = 'mockRegex';
customParameterPostParams.regexComment = 'mockComment';
customParameterPostParams.isOptional = false;
customParameterPostParams.isProtected = false;

const externalToolCreateParams = new ExternalToolCreateParams();
externalToolCreateParams.name = 'mockName';
Expand Down Expand Up @@ -159,6 +160,7 @@ describe('ExternalToolRequestMapper', () => {
customParameterPostParams.regex = 'mockRegex';
customParameterPostParams.regexComment = 'mockComment';
customParameterPostParams.isOptional = false;
customParameterPostParams.isProtected = false;

const externalToolCreateParams = new ExternalToolCreateParams();
externalToolCreateParams.name = 'mockName';
Expand Down Expand Up @@ -244,6 +246,7 @@ describe('ExternalToolRequestMapper', () => {
customParameterPostParams.regex = 'mockRegex';
customParameterPostParams.regexComment = 'mockComment';
customParameterPostParams.isOptional = false;
customParameterPostParams.isProtected = false;

const externalToolCreateParams = new ExternalToolCreateParams();
externalToolCreateParams.name = 'mockName';
Expand Down Expand Up @@ -312,6 +315,7 @@ describe('ExternalToolRequestMapper', () => {
customParameterPostParams.regex = 'mockRegex';
customParameterPostParams.regexComment = 'mockComment';
customParameterPostParams.isOptional = false;
customParameterPostParams.isProtected = false;

const externalToolUpdateParams = new ExternalToolUpdateParams();
externalToolUpdateParams.id = 'id';
Expand Down Expand Up @@ -404,6 +408,7 @@ describe('ExternalToolRequestMapper', () => {
customParameterPostParams.regex = 'mockRegex';
customParameterPostParams.regexComment = 'mockComment';
customParameterPostParams.isOptional = false;
customParameterPostParams.isProtected = false;

const externalToolUpdateParams = new ExternalToolUpdateParams();
externalToolUpdateParams.id = 'id';
Expand Down Expand Up @@ -493,6 +498,7 @@ describe('ExternalToolRequestMapper', () => {
customParameterPostParams.regex = 'mockRegex';
customParameterPostParams.regexComment = 'mockComment';
customParameterPostParams.isOptional = false;
customParameterPostParams.isProtected = false;

const externalToolUpdateParams = new ExternalToolUpdateParams();
externalToolUpdateParams.id = 'id';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export class ExternalToolRequestMapper {
location: locationMapping[customParameterParam.location],
type: typeMapping[customParameterParam.type],
isOptional: customParameterParam.isOptional,
isProtected: customParameterParam.isProtected,
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('ExternalToolResponseMapper', () => {
regex: 'mockRegex',
regexComment: 'mockComment',
isOptional: false,
isProtected: false,
});

const basicToolConfigResponse: BasicToolConfigResponse = new BasicToolConfigResponse({
Expand Down Expand Up @@ -143,6 +144,7 @@ describe('ExternalToolResponseMapper', () => {
regex: 'mockRegex',
regexComment: 'mockComment',
isOptional: false,
isProtected: false,
});

const externalToolResponse: ExternalToolResponse = new ExternalToolResponse({
Expand Down Expand Up @@ -230,6 +232,7 @@ describe('ExternalToolResponseMapper', () => {
regex: 'mockRegex',
regexComment: 'mockComment',
isOptional: false,
isProtected: false,
});

const externalToolResponse: ExternalToolResponse = new ExternalToolResponse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class ExternalToolResponseMapper {
location: locationMapping[customParameterDO.location],
type: typeMapping[customParameterDO.type],
isOptional: customParameterDO.isOptional,
isProtected: customParameterDO.isProtected,
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('ExternalToolVersionService', () => {
displayName: 'displayName',
default: 'defaulValueParam1',
isOptional: false,
isProtected: false,
location: CustomParameterLocation.PATH,
regex: '*',
regexComment: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('SchoolExternalToolEntity', () => {
regex: 'mockRegex',
regexComment: 'mockComment',
isOptional: false,
isProtected: false,
});
const externalToolEntity: ExternalToolEntity = new ExternalToolEntity({
name: 'toolName',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ describe('ExternalToolRepo', () => {
location: CustomParameterLocation.BODY,
regexComment: 'mockComment',
isOptional: false,
isProtected: false,
}),
],
isHidden: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class ExternalToolRepoMapper {
location: param.location,
type: param.type,
isOptional: param.isOptional,
isProtected: param.isProtected,
})
);
}
Expand All @@ -167,6 +168,7 @@ export class ExternalToolRepoMapper {
location: param.location,
type: param.type,
isOptional: param.isOptional,
isProtected: param.isProtected,
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const customParameterFactory = CustomParameterFactory.define(CustomParame
scope: CustomParameterScope.SCHOOL,
location: CustomParameterLocation.BODY,
isOptional: false,
isProtected: false,
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const customParameterEntityFactory = BaseFactory.define<CustomParameterEn
scope: CustomParameterScope.SCHOOL,
type: CustomParameterType.STRING,
isOptional: false,
isProtected: false,
};
}
);
Expand Down
27 changes: 18 additions & 9 deletions backup/setup/external-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"scope": "global",
"location": "query",
"type": "string",
"isOptional": false
"isOptional": false,
"isProtected": false
},
{
"name": "search",
Expand All @@ -34,7 +35,8 @@
"scope": "global",
"location": "path",
"type": "string",
"isOptional": false
"isOptional": false,
"isProtected": false
},
{
"name": "param1",
Expand All @@ -43,7 +45,8 @@
"scope": "school",
"location": "path",
"type": "string",
"isOptional": true
"isOptional": true,
"isProtected": false
},
{
"name": "contextParam",
Expand All @@ -54,7 +57,8 @@
"scope": "context",
"location": "query",
"type": "string",
"isOptional": false
"isOptional": false,
"isProtected": false
}
],
"isHidden": false,
Expand Down Expand Up @@ -93,7 +97,8 @@
"scope": "global",
"location": "body",
"type": "string",
"isOptional": false
"isOptional": false,
"isProtected": false
}
],
"isHidden": false,
Expand Down Expand Up @@ -142,7 +147,8 @@
"scope": "school",
"location": "path",
"type": "string",
"isOptional": false
"isOptional": false,
"isProtected": false
}],
"isHidden": false,
"openNewTab": false,
Expand All @@ -168,7 +174,8 @@
"scope": "context",
"location": "path",
"type": "string",
"isOptional": false
"isOptional": false,
"isProtected": false
}],
"isHidden": false,
"openNewTab": false,
Expand All @@ -194,15 +201,17 @@
"scope": "school",
"location": "path",
"type": "string",
"isOptional": false
"isOptional": false,
"isProtected": false
}, {
"name": "contextparammm",
"displayName": "cypress test context",
"description": "",
"scope": "context",
"location": "path",
"type": "string",
"isOptional": false
"isOptional": false,
"isProtected": false
}],
"isHidden": false,
"openNewTab": false,
Expand Down
11 changes: 11 additions & 0 deletions backup/setup/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,5 +372,16 @@
"$date": "2023-12-11T09:52:27.346Z"
},
"__v": 0
},
{
"_id": {
"$oid": "658434b45fcf755f84d80cb6"
},
"state": "up",
"name": "add-protected-field-to-custom-paramters",
"createdAt": {
"$date": "2023-12-20T11:44:04.729Z"
},
"__v": 0
}
]
Loading

0 comments on commit a13a017

Please sign in to comment.