Skip to content

Commit

Permalink
chore: update auth plugin tip (#2004)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiteSun authored Aug 9, 2021
1 parent 3236c08 commit c3ea687
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ context('Create and Delete Consumer', () => {
serviceSelector: '[title=test_service]',
monacoScroll: '.monaco-scrollable-element',
monacoViewZones: '.view-zones',
notificationCloseIcon: '.ant-notification-close-icon'
};

const data = {
Expand Down Expand Up @@ -56,6 +57,13 @@ context('Create and Delete Consumer', () => {
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({
Expand All @@ -66,9 +74,15 @@ context('Create and Delete Consumer', () => {
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();
Expand Down Expand Up @@ -113,9 +127,15 @@ context('Create and Delete Consumer', () => {
});

// 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);
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Plugin/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export const PLUGIN_LIST = {
type: PluginType.security,
},
'wolf-rbac': {
type: PluginType.other,
type: PluginType.authentication,
},
'authz-keycloak': {
type: PluginType.authentication,
Expand Down
14 changes: 11 additions & 3 deletions web/src/pages/Consumer/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const Page: React.FC = (props) => {
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();

Expand All @@ -43,7 +44,14 @@ const Page: React.FC = (props) => {
});
}

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 = () => {
Expand Down Expand Up @@ -82,9 +90,9 @@ const Page: React.FC = (props) => {
).length
) {
notification.warning({
message: formatMessage({
message: `${formatMessage({
id: 'page.consumer.notification.warning.enableAuthenticationPlugin',
}),
})} ${authPluginList.join(', ')}`,
});
return;
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Consumer/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {
'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',
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Consumer/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
'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': '更新时间',
Expand Down

0 comments on commit c3ea687

Please sign in to comment.