Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: basic support Apache APISIX 2.11 #2233

Merged
merged 16 commits into from
Dec 3, 2021
3,345 changes: 2,331 additions & 1,014 deletions api/conf/schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/internal/handler/schema/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestPlugin(t *testing.T) {
}
}
// plugin type
assert.ElementsMatch(t, []string{"basic-auth", "jwt-auth", "hmac-auth", "key-auth", "wolf-rbac"}, authPlugins)
assert.ElementsMatch(t, []string{"basic-auth", "jwt-auth", "hmac-auth", "key-auth", "wolf-rbac", "ldap-auth"}, authPlugins)
// consumer schema
assert.Equal(t, `{"properties":{"password":{"type":"string"},"username":{"type":"string"}},"required":["password","username"],"title":"work with consumer object","type":"object"}`, basicAuthConsumerSchema)
}
2 changes: 1 addition & 1 deletion web/cypress/fixtures/plugin-dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@
"data": { "count": 2, "time_window": 60, "rejected_code": 503, "key": "remote_addr" }
},
{
"shouldValid": false,
"shouldValid": true,
"data": {
"count": 2,
"time_window": 60,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ context('Create and Delete Consumer', () => {
burst: '#burst',
key: '#key',
nodelay: '#nodelay',
remote_addr: '[title=remote_addr]',
monacoViewZones: '.view-zones',
};

Expand All @@ -40,6 +39,7 @@ context('Create and Delete Consumer', () => {
createConsumerSuccess: 'Create Consumer Successfully',
deleteConsumerSuccess: 'Delete Consumer Successfully',
time: 2,
key: 'remote_addr',
};

beforeEach(() => {
Expand Down Expand Up @@ -87,8 +87,7 @@ context('Create and Delete Consumer', () => {

cy.get(selector.rate).type(data.time);
cy.get(selector.burst).type(data.time);
cy.get(selector.key).click();
cy.get(selector.remote_addr).click();
cy.get(selector.key).type(data.key);
cy.get(selector.nodelay).click();
cy.get(selector.drawer).within(() => {
cy.contains('Submit').click({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ context('Create and delete consumer with limit-conn plugin form', () => {
only_use_default_delay: '#only_use_default_delay',
key: '#key',
rejected_code: '#rejected_code',
title: '[title="remote_addr"]',
monacoViewZones: '.view-zones',
};

Expand Down Expand Up @@ -91,11 +90,7 @@ context('Create and delete consumer with limit-conn plugin form', () => {
cy.get(selector.burst).type(data.burst);
cy.get(selector.default_conn_delay).type(data.default_conn_delay);
cy.get(selector.only_use_default_delay).click();
cy.get(selector.key).click();
cy.get(selector.selectDropdown).should('be.visible');
cy.get(selector.title).click({
timeout: 5000,
});
cy.get(selector.key).type(data.key);
cy.get(selector.disabledSwitcher).click();
cy.get(selector.drawer).within(() => {
cy.contains('Submit').click({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ context('Create and Delete Consumer', () => {
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',
'Please enable at least one of the following authentication plugin: basic-auth, hmac-auth, jwt-auth, key-auth, ldap-auth, wolf-rbac',
);
cy.get(selector.notificationCloseIcon).click().should('not.exist');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ context('Create and delete route with limit-req form', () => {
rate: '#rate',
burst: '#burst',
key: '#key',
remote_addr: '[title=remote_addr]',
};

const data = {
deleteRouteSuccess: 'Delete Route Successfully',
submitSuccess: 'Submit Successfully',
port: '80',
weight: 1,
key: 'remote_addr',
};

beforeEach(() => {
Expand Down Expand Up @@ -91,8 +91,7 @@ context('Create and delete route with limit-req form', () => {
// config limit-req form
cy.get(selector.rate).type(1);
cy.get(selector.burst).type(0);
cy.get(selector.key).click();
cy.get(selector.remote_addr).click();
cy.get(selector.key).type(data.key);
cy.get(selector.drawer).within(() => {
cy.contains('Submit').click({
force: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ context('create route with proxy-rewrite plugin', () => {
uriRewriteReg: '#proxyRewrite_regex_uri_0',
uriRewriteTemp: '#proxyRewrite_regex_uri_1',
newHost: '#proxyRewrite_host',
methodRewriteSelect: '[data-cy=proxyRewrite-method]',
methodRewriteSelectOption: '.ant-select-item-option',
buttonCreateNewRewriteHeader: '[data-cy=create-new-rewrite-header]',
rewriteHeaderKey1: '#proxyRewrite_kvHeaders_0_key',
rewriteHeaderValue1: '#proxyRewrite_kvHeaders_0_value',
Expand Down Expand Up @@ -93,6 +95,10 @@ context('create route with proxy-rewrite plugin', () => {
cy.get(selector.keepHost).click();
cy.get(selector.newHost).should('not.exist');

// method rewrite
cy.get(selector.methodRewriteSelect).click();
cy.get(selector.methodRewriteSelectOption).contains('POST').click();

// new header key value input after createNewRewriteHeader button clicked
cy.get(selector.buttonCreateNewRewriteHeader).click();
cy.get(selector.rewriteHeaderKey1).should('be.visible').type(data.rewriteHeaderKey1);
Expand Down Expand Up @@ -130,6 +136,8 @@ context('create route with proxy-rewrite plugin', () => {

cy.get(selector.newHost).should('not.exist');

cy.get(selector.methodRewriteSelect).contains('POST').should('exist');

cy.get(selector.rewriteHeaderKey1).should('have.value', data.rewriteHeaderKey1);
cy.get(selector.rewriteHeaderValue1).should('have.value', data.rewriteHeaderValue1);
cy.get(selector.rewriteHeaderKey2).should('have.value', data.rewriteHeaderKey2);
Expand Down
18 changes: 13 additions & 5 deletions web/src/components/Plugin/UI/limit-conn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ const LimitConn: React.FC<Props> = ({ form, schema }) => {
<Switch defaultChecked={onlyUseDefaultDelay} />
</Form.Item>
<Form.Item
label="key"
required
name="key"
tooltip={formatMessage({ id: 'component.pluginForm.limit-conn.key.tooltip' })}
label="key_type"
name="key_type"
tooltip={formatMessage({ id: 'component.pluginForm.limit-conn.key_type.tooltip' })}
initialValue={properties.key_type.default}
>
<Select>
{properties.key.enum.map((item: string) => {
{properties.key_type.enum.map((item: string) => {
return (
<Select.Option value={item} key={item}>
{item}
Expand All @@ -98,6 +98,14 @@ const LimitConn: React.FC<Props> = ({ form, schema }) => {
})}
</Select>
</Form.Item>
<Form.Item
label="key"
name="key"
required
tooltip={formatMessage({ id: 'component.pluginForm.limit-conn.key.tooltip' })}
>
<Input min={1} />
</Form.Item>
<Form.Item
label="rejected_code"
name="rejected_code"
Expand Down
Loading