Skip to content

Commit 59ea8c6

Browse files
iamayushdasfoolwc
andauthored
fix: validate rules in Apisix Dashboard is same as Apisix api (#2085)
Co-authored-by: foolwc <[email protected]>
1 parent d3e1861 commit 59ea8c6

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

docs/en/latest/I18N_USER_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ we have already defined many global keys, before you do i18n, you can refer to [
6464

6565
```js
6666
'page.route.form.itemRulesExtraMessage.parameterName': '仅支持字母和数字,且只能以字母开头',
67-
'page.route.form.itemRulesPatternMessage.apiNameRule': '最大长度100,仅支持字母、数字、- 和 _,且只能以字母开头',
67+
'page.route.form.itemRulesPatternMessage.apiNameRule': '最大长度应小于100',
6868
```
6969

7070
- **Input**

web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ context('Create and Delete Route', () => {
5353
notification: '.ant-notification-notice-message',
5454
addHost: '[data-cy=addHost]',
5555
schemaErrorMessage: '.ant-form-item-explain.ant-form-item-explain-error',
56+
stepCheck: '.ant-steps-finish-icon',
5657
advancedMatchingTable: '.ant-table-row.ant-table-row-level-0',
5758
advancedMatchingTableOperation: '.ant-space',
5859
};
5960

6061
const data = {
6162
description: 'desc_by_autotest',
63+
invalidName: new Array(101).fill('a').join(''),
6264
host1: '11.11.11.11',
6365
host2: '12.12.12.12',
6466
host3: '10.10.10.10',
@@ -83,6 +85,20 @@ context('Create and Delete Route', () => {
8385
cy.login();
8486
});
8587

88+
it.only('should not create route with name above 100 characters', function () {
89+
cy.visit('/');
90+
cy.contains('Route').click();
91+
cy.get(selector.empty).should('be.visible');
92+
cy.contains('Create').click();
93+
cy.contains('Next').click();
94+
cy.get(selector.name).type(data.invalidName);
95+
cy.contains(selector.schemaErrorMessage, 'Maximum length should be of 100 only').should(
96+
'be.visible',
97+
);
98+
cy.contains('Next').click();
99+
cy.get(selector.stepCheck).should('not.exist');
100+
});
101+
86102
it('should create route', function () {
87103
cy.visit('/');
88104
cy.contains('Route').click();

web/src/pages/Route/components/Step1/MetaView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const MetaView: React.FC<RouteModule.Step1PassProps> = ({
136136
}),
137137
},
138138
{
139-
pattern: new RegExp(/^[a-zA-Z][a-zA-Z0-9_-]{0,100}$/, 'g'),
139+
pattern: new RegExp(/^.{0,100}$/, 'g'),
140140
message: formatMessage({
141141
id: 'page.route.form.itemRulesPatternMessage.apiNameRule',
142142
}),

web/src/pages/Route/locales/en-US.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ export default {
5656
'page.route.panelSection.title.advancedMatchRule': 'Advanced Routing Matching Conditions',
5757

5858
'page.route.panelSection.title.nameDescription': 'Name And Description',
59-
'page.route.form.itemRulesPatternMessage.apiNameRule':
60-
'Maximum length 100, only letters, Numbers, _, and - are supported, and can only begin with letters',
59+
'page.route.form.itemRulesPatternMessage.apiNameRule': 'Maximum length should be of 100 only',
6160

6261
'page.route.panelSection.title.requestConfigBasicDefine': 'Request Basic Define',
6362
'page.route.form.itemLabel.httpMethod': 'HTTP Method',

web/src/pages/Route/locales/zh-CN.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ export default {
6565
'page.route.input.placeholder.paramValue': '参数值',
6666
// form
6767
'page.route.form.itemRulesRequiredMessage.parameterName': '仅支持字母和数字,且只能以字母开头',
68-
'page.route.form.itemRulesPatternMessage.apiNameRule':
69-
'路由的名称,最大长度100,仅支持字母、数字、- 和 _,且只能以字母开头',
68+
'page.route.form.itemRulesPatternMessage.apiNameRule': '最大长度应仅为 100',
7069
'page.route.form.itemLabel.httpMethod': 'HTTP 方法',
7170
'page.route.form.itemLabel.scheme': '协议',
7271
'page.route.form.itemLabel.priority': '优先级',

0 commit comments

Comments
 (0)