You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by li...@apache.org on 2021/09/01 01:57:31 UTC
[apisix-dashboard] branch master updated: fix: validate rules in
Apisix Dashboard is same as Apisix api (#2085)
This is an automated email from the ASF dual-hosted git repository.
liuxiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 59ea8c6 fix: validate rules in Apisix Dashboard is same as Apisix api (#2085)
59ea8c6 is described below
commit 59ea8c6866c629dd331b1cb7005e62f96f9a9ea9
Author: Ayush das <ay...@gmail.com>
AuthorDate: Wed Sep 1 07:27:24 2021 +0530
fix: validate rules in Apisix Dashboard is same as Apisix api (#2085)
Co-authored-by: foolwc <29...@qq.com>
---
docs/en/latest/I18N_USER_GUIDE.md | 2 +-
.../route/create-edit-duplicate-delete-route.spec.js | 16 ++++++++++++++++
web/src/pages/Route/components/Step1/MetaView.tsx | 2 +-
web/src/pages/Route/locales/en-US.ts | 3 +--
web/src/pages/Route/locales/zh-CN.ts | 3 +--
5 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/docs/en/latest/I18N_USER_GUIDE.md b/docs/en/latest/I18N_USER_GUIDE.md
index 1bdb051..bf7419f 100644
--- a/docs/en/latest/I18N_USER_GUIDE.md
+++ b/docs/en/latest/I18N_USER_GUIDE.md
@@ -64,7 +64,7 @@ we have already defined many global keys, before you do i18n, you can refer to [
```js
'page.route.form.itemRulesExtraMessage.parameterName': '仅支持字母和数字,且只能以字母开头',
-'page.route.form.itemRulesPatternMessage.apiNameRule': '最大长度100,仅支持字母、数字、- 和 _,且只能以字母开头',
+'page.route.form.itemRulesPatternMessage.apiNameRule': '最大长度应小于100',
```
- **Input**
diff --git a/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js b/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js
index 9031b9a..1cf49f9 100644
--- a/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js
+++ b/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js
@@ -53,12 +53,14 @@ context('Create and Delete Route', () => {
notification: '.ant-notification-notice-message',
addHost: '[data-cy=addHost]',
schemaErrorMessage: '.ant-form-item-explain.ant-form-item-explain-error',
+ stepCheck: '.ant-steps-finish-icon',
advancedMatchingTable: '.ant-table-row.ant-table-row-level-0',
advancedMatchingTableOperation: '.ant-space',
};
const data = {
description: 'desc_by_autotest',
+ invalidName: new Array(101).fill('a').join(''),
host1: '11.11.11.11',
host2: '12.12.12.12',
host3: '10.10.10.10',
@@ -83,6 +85,20 @@ context('Create and Delete Route', () => {
cy.login();
});
+ it.only('should not create route with name above 100 characters', function () {
+ cy.visit('/');
+ cy.contains('Route').click();
+ cy.get(selector.empty).should('be.visible');
+ cy.contains('Create').click();
+ cy.contains('Next').click();
+ cy.get(selector.name).type(data.invalidName);
+ cy.contains(selector.schemaErrorMessage, 'Maximum length should be of 100 only').should(
+ 'be.visible',
+ );
+ cy.contains('Next').click();
+ cy.get(selector.stepCheck).should('not.exist');
+ });
+
it('should create route', function () {
cy.visit('/');
cy.contains('Route').click();
diff --git a/web/src/pages/Route/components/Step1/MetaView.tsx b/web/src/pages/Route/components/Step1/MetaView.tsx
index 7309f14..43cf7e3 100644
--- a/web/src/pages/Route/components/Step1/MetaView.tsx
+++ b/web/src/pages/Route/components/Step1/MetaView.tsx
@@ -136,7 +136,7 @@ const MetaView: React.FC<RouteModule.Step1PassProps> = ({
}),
},
{
- pattern: new RegExp(/^[a-zA-Z][a-zA-Z0-9_-]{0,100}$/, 'g'),
+ pattern: new RegExp(/^.{0,100}$/, 'g'),
message: formatMessage({
id: 'page.route.form.itemRulesPatternMessage.apiNameRule',
}),
diff --git a/web/src/pages/Route/locales/en-US.ts b/web/src/pages/Route/locales/en-US.ts
index 39b97e1..23c9184 100644
--- a/web/src/pages/Route/locales/en-US.ts
+++ b/web/src/pages/Route/locales/en-US.ts
@@ -56,8 +56,7 @@ export default {
'page.route.panelSection.title.advancedMatchRule': 'Advanced Routing Matching Conditions',
'page.route.panelSection.title.nameDescription': 'Name And Description',
- 'page.route.form.itemRulesPatternMessage.apiNameRule':
- 'Maximum length 100, only letters, Numbers, _, and - are supported, and can only begin with letters',
+ 'page.route.form.itemRulesPatternMessage.apiNameRule': 'Maximum length should be of 100 only',
'page.route.panelSection.title.requestConfigBasicDefine': 'Request Basic Define',
'page.route.form.itemLabel.httpMethod': 'HTTP Method',
diff --git a/web/src/pages/Route/locales/zh-CN.ts b/web/src/pages/Route/locales/zh-CN.ts
index 86105e4..30112ab 100644
--- a/web/src/pages/Route/locales/zh-CN.ts
+++ b/web/src/pages/Route/locales/zh-CN.ts
@@ -65,8 +65,7 @@ export default {
'page.route.input.placeholder.paramValue': '参数值',
// form
'page.route.form.itemRulesRequiredMessage.parameterName': '仅支持字母和数字,且只能以字母开头',
- 'page.route.form.itemRulesPatternMessage.apiNameRule':
- '路由的名称,最大长度100,仅支持字母、数字、- 和 _,且只能以字母开头',
+ 'page.route.form.itemRulesPatternMessage.apiNameRule': '最大长度应仅为 100',
'page.route.form.itemLabel.httpMethod': 'HTTP 方法',
'page.route.form.itemLabel.scheme': '协议',
'page.route.form.itemLabel.priority': '优先级',