Skip to content

Commit addd201

Browse files
replaced nameRegex with bitBucketUserNameRegex, err.type required, subject.name
1 parent ea4f066 commit addd201

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { UserRoleBinding, RoleBinding } from '../project-access-form-utils-types
33
export const mockProjectAccessData = {
44
projectAccess: [
55
{
6-
user: 'abc',
6+
subject: {
7+
name: 'abc',
8+
kind: 'User',
9+
},
710
role: 'view',
811
},
912
],

frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-validation-utils.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { mockProjectAccessData } from './project-access-form-data';
55
describe('ValidationUtils', () => {
66
it('should throw an error if Name field is empty', async () => {
77
const mockData = cloneDeep(mockProjectAccessData);
8-
mockData.projectAccess[0].user = '';
8+
mockData.projectAccess[0].subject.name = '';
99

1010
await validationSchema.isValid(mockData).then((valid) => expect(valid).toEqual(false));
1111
await validationSchema.validate(mockData).catch((err) => {
1212
expect(err.message).toBe('Required');
13-
expect(err.type).toBe('optionality');
13+
expect(err.type).toBe('required');
1414
});
1515
});
1616

frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ export const pipelinesAccessTokenValidationSchema = (t: TFunction) =>
8383
schema.shape({
8484
user: yup
8585
.string()
86-
.matches(nameRegex, {
86+
.matches(bitBucketUserNameRegex, {
8787
message: t(
88-
'pipelines-plugin~Name must consist of lower-case letters, numbers and hyphens. It must start with a letter and end with a letter or number.',
88+
'pipelines-plugin~Name must consist of lower-case letters, numbers, underscores and hyphens. It must start with a letter and end with a letter or number.',
8989
),
9090
excludeEmptyString: true,
9191
})

0 commit comments

Comments
 (0)