chore: update auth plugin tip (#2004)
diff --git a/web/cypress/integration/consumer/create_and_delete_consumer.spec.js b/web/cypress/integration/consumer/create_and_delete_consumer.spec.js
index b510e20..81cf2c9 100644
--- a/web/cypress/integration/consumer/create_and_delete_consumer.spec.js
+++ b/web/cypress/integration/consumer/create_and_delete_consumer.spec.js
@@ -29,6 +29,7 @@
serviceSelector: '[title=test_service]',
monacoScroll: '.monaco-scrollable-element',
monacoViewZones: '.view-zones',
+ notificationCloseIcon: '.ant-notification-close-icon'
};
const data = {
@@ -56,6 +57,13 @@
cy.get(selector.description).type(data.description);
cy.contains('Next').click();
+ cy.contains('Next').click();
+ cy.get(selector.notification).should(
+ 'contain',
+ 'Please enable at least one of the following authentication plugin: basic-auth, hmac-auth, jwt-auth, key-auth, wolf-rbac',
+ );
+ cy.get(selector.notificationCloseIcon).click().should('not.exist');
+
// plugin config
cy.contains(selector.pluginCard, 'key-auth').within(() => {
cy.contains('Enable').click({
@@ -66,9 +74,15 @@
cy.get(selector.disabledSwitcher).click();
// edit monaco
- cy.get(selector.monacoViewZones).should('exist').click({ force: true });
+ cy.get(selector.monacoViewZones).should('exist').click({
+ force: true,
+ });
cy.window().then((window) => {
- window.monacoEditor.setValue(JSON.stringify({ key: 'test' }));
+ window.monacoEditor.setValue(
+ JSON.stringify({
+ key: 'test',
+ }),
+ );
cy.contains('button', 'Submit').click();
});
cy.contains('button', 'Next').click();
@@ -113,9 +127,15 @@
});
// edit monaco
- cy.get(selector.monacoViewZones).should('exist').click({ force: true });
+ cy.get(selector.monacoViewZones).should('exist').click({
+ force: true,
+ });
cy.window().then((window) => {
- window.monacoEditor.setValue(JSON.stringify({ key_not_exist: 'test' }));
+ window.monacoEditor.setValue(
+ JSON.stringify({
+ key_not_exist: 'test',
+ }),
+ );
cy.contains('button', 'Submit').click();
});
cy.get(selector.notification).should('contain', data.pluginErrorAlert);
diff --git a/web/src/components/Plugin/data.tsx b/web/src/components/Plugin/data.tsx
index 1cfd297..79d1dfb 100644
--- a/web/src/components/Plugin/data.tsx
+++ b/web/src/components/Plugin/data.tsx
@@ -212,7 +212,7 @@
type: PluginType.security,
},
'wolf-rbac': {
- type: PluginType.other,
+ type: PluginType.authentication,
},
'authz-keycloak': {
type: PluginType.authentication,
diff --git a/web/src/pages/Consumer/Create.tsx b/web/src/pages/Consumer/Create.tsx
index 8f8f765..a36a77f 100644
--- a/web/src/pages/Consumer/Create.tsx
+++ b/web/src/pages/Consumer/Create.tsx
@@ -30,6 +30,7 @@
const [step, setStep] = useState(1);
const [plugins, setPlugins] = useState<PluginComponent.Data>({});
const [pluginList, setPluginList] = useState<PluginComponent.Meta[]>([]);
+ const [authPluginList, setAuthPluginList] = useState<string[]>([]);
const [form1] = Form.useForm();
const { formatMessage } = useIntl();
@@ -43,7 +44,14 @@
});
}
- fetchPlugList().then(setPluginList);
+ fetchPlugList().then((data) => {
+ setPluginList(data);
+ const authList = data
+ .filter((item) => item.type === 'auth')
+ .map((item) => item.name)
+ .sort();
+ setAuthPluginList(authList);
+ });
}, []);
const onSubmit = () => {
@@ -82,9 +90,9 @@
).length
) {
notification.warning({
- message: formatMessage({
+ message: `${formatMessage({
id: 'page.consumer.notification.warning.enableAuthenticationPlugin',
- }),
+ })} ${authPluginList.join(', ')}`,
});
return;
}
diff --git a/web/src/pages/Consumer/locales/en-US.ts b/web/src/pages/Consumer/locales/en-US.ts
index 9fabb89..86836b7 100644
--- a/web/src/pages/Consumer/locales/en-US.ts
+++ b/web/src/pages/Consumer/locales/en-US.ts
@@ -19,7 +19,7 @@
'Maximum length is 100, only letters, numbers and _ are supported, and can only begin with letters',
'page.consumer.form.itemExtraMessage.username': 'Name should be unique',
'page.consumer.notification.warning.enableAuthenticationPlugin':
- 'Please enable one authentication plugin',
+ 'Please enable at least one of the following authentication plugin:',
'page.consumer.username': 'Name',
'page.consumer.username.required': "Please enter the Consumer's name",
'page.consumer.updateTime': 'Update Time',
diff --git a/web/src/pages/Consumer/locales/zh-CN.ts b/web/src/pages/Consumer/locales/zh-CN.ts
index 0218657..5ab9398 100644
--- a/web/src/pages/Consumer/locales/zh-CN.ts
+++ b/web/src/pages/Consumer/locales/zh-CN.ts
@@ -18,7 +18,7 @@
'page.consumer.form.itemRuleMessage.username':
'最大长度100,仅支持字母、数字和 _ ,且只能以字母开头',
'page.consumer.form.itemExtraMessage.username': '名称需唯一',
- 'page.consumer.notification.warning.enableAuthenticationPlugin': '请启用一种身份认证类插件',
+ 'page.consumer.notification.warning.enableAuthenticationPlugin': '请至少启用如下一种认证类插件:',
'page.consumer.username': '名称',
'page.consumer.username.required': '请输入消费者名称',
'page.consumer.updateTime': '更新时间',