Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6ff637

Browse files
authored
chore: backport commits to 2.15 (#2764)
1 parent 3e6f822 commit f6ff637

File tree

6 files changed

+61
-18
lines changed

6 files changed

+61
-18
lines changed

api/internal/core/entity/entity.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ type Route struct {
6565
BaseInfo
6666
URI string `json:"uri,omitempty"`
6767
Uris []string `json:"uris,omitempty"`
68-
Name string `json:"name" validate:"max=50"`
69-
Desc string `json:"desc,omitempty" validate:"max=256"`
68+
Name string `json:"name"`
69+
Desc string `json:"desc,omitempty"`
7070
Priority int `json:"priority,omitempty"`
7171
Methods []string `json:"methods,omitempty"`
7272
Host string `json:"host,omitempty"`
@@ -280,7 +280,7 @@ type ServerInfo struct {
280280
// swagger:model GlobalPlugins
281281
type PluginConfig struct {
282282
BaseInfo
283-
Desc string `json:"desc,omitempty" validate:"max=256"`
283+
Desc string `json:"desc,omitempty"`
284284
Plugins map[string]interface{} `json:"plugins"`
285285
Labels map[string]string `json:"labels,omitempty"`
286286
}

api/test/e2e/route/route_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@ var _ = Describe("Route", func() {
6464
Headers: map[string]string{"Authorization": base.GetToken()},
6565
ExpectStatus: http.StatusOK,
6666
}),
67+
Entry("create long name route3 success", base.HttpTestCase{
68+
Object: base.ManagerApiExpect(),
69+
Method: http.MethodPut,
70+
Path: "/apisix/admin/routes/r3",
71+
Body: `{
72+
"name": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
73+
"uri": "/hello_",
74+
"upstream": {
75+
"nodes": {
76+
"` + base.UpstreamIp + `:1980": 1
77+
},
78+
"type": "roundrobin"
79+
}
80+
}`,
81+
Headers: map[string]string{"Authorization": base.GetToken()},
82+
ExpectStatus: http.StatusOK,
83+
}),
6784
Entry("create route failed, name existed", base.HttpTestCase{
6885
Object: base.ManagerApiExpect(),
6986
Method: http.MethodPost,
@@ -147,6 +164,13 @@ var _ = Describe("Route", func() {
147164
Headers: map[string]string{"Authorization": base.GetToken()},
148165
ExpectStatus: http.StatusOK,
149166
}),
167+
Entry("delete route3", base.HttpTestCase{
168+
Object: base.ManagerApiExpect(),
169+
Method: http.MethodDelete,
170+
Path: "/apisix/admin/routes/r3",
171+
Headers: map[string]string{"Authorization": base.GetToken()},
172+
ExpectStatus: http.StatusOK,
173+
}),
150174
Entry("hit route1 that just deleted", base.HttpTestCase{
151175
Object: base.APISIXExpect(),
152176
Method: http.MethodGet,

web/cypress/e2e/route/create-route-with-proxy-rewrite-plugin.cy.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* limitations under the License.
1616
*/
1717
/* eslint-disable no-undef */
18-
import menuLocaleUS from '../../../src/locales/en-US/menu';
1918
import componentLocaleUS from '../../../src/locales/en-US/component';
19+
import menuLocaleUS from '../../../src/locales/en-US/menu';
2020
import routeLocaleUS from '../../../src/pages/Route/locales/en-US';
2121

2222
context('create route with proxy-rewrite plugin', () => {
@@ -29,6 +29,7 @@ context('create route with proxy-rewrite plugin', () => {
2929
deleteAlert: '.ant-modal-body',
3030
notification: '.ant-notification-notice-message',
3131
staticUri: '[data-cy=uri-static]',
32+
regexUri: '[data-cy=uri-regex]',
3233
staticHost: '[data-cy=host-static]',
3334
keepHost: '[data-cy=host-keep]',
3435
newUri: '#proxyRewrite_uri',
@@ -56,6 +57,7 @@ context('create route with proxy-rewrite plugin', () => {
5657
rewriteHeaderKey2: 'test2',
5758
rewriteHeaderValue1: '1',
5859
rewriteHeaderValue2: '2',
60+
regex: '^/iresty/(.)/(.)/(.*)',
5961
};
6062

6163
beforeEach(() => {
@@ -154,6 +156,30 @@ context('create route with proxy-rewrite plugin', () => {
154156
cy.contains(data.submitSuccess).should('be.visible');
155157
});
156158

159+
it('should use proxy rewrite in regex uri moode without template', () => {
160+
cy.visit('/');
161+
cy.contains(menuLocaleUS['menu.routes']).click();
162+
163+
cy.get(selector.nameSelector).type(data.routeName);
164+
cy.contains('Search').click();
165+
cy.contains(data.routeName).siblings().contains('Configure').click();
166+
167+
cy.get('#status').should('have.class', 'ant-switch-checked');
168+
cy.get(selector.regexUri).click();
169+
cy.get(selector.uriRewriteReg).should('be.visible').type(data.regex);
170+
cy.get(selector.uriRewriteTemp).should('have.value', '');
171+
cy.contains('Next').click();
172+
cy.get(selector.nodes_0_host).type(data.host2);
173+
cy.get(selector.nodes_0_port).type(data.port);
174+
cy.get(selector.nodes_0_weight).type(data.weight);
175+
cy.contains('Next').click();
176+
177+
cy.contains('proxy-rewrite').should('not.exist');
178+
cy.contains('Next').click();
179+
cy.contains('Submit').click();
180+
cy.contains(data.submitSuccess).should('be.visible');
181+
});
182+
157183
it('should delete the route', function () {
158184
cy.visit('/routes/list');
159185
cy.get(selector.nameSelector).type(data.routeName);

web/src/helpers.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { FileTextOutlined, InfoCircleOutlined } from '@ant-design/icons';
1818
import type { MenuDataItem } from '@ant-design/pro-layout';
1919
import { notification } from 'antd';
2020
import yaml from 'js-yaml';
21+
import { isNumber } from 'lodash';
2122
import moment from 'moment';
2223
import React from 'react';
2324
import { history } from 'umi';
@@ -128,12 +129,11 @@ export const getUrlQuery: (key: string) => string | false = (key: string) => {
128129
};
129130

130131
export const timestampToLocaleString = (timestamp: number) => {
131-
if (!timestamp) {
132-
// TODO: i18n
133-
return 'None';
132+
if (isNumber(timestamp)) {
133+
return moment.unix(timestamp).format('YYYY-MM-DD HH:mm:ss');
134134
}
135135

136-
return moment.unix(timestamp).format('YYYY-MM-DD HH:mm:ss');
136+
return 'None';
137137
};
138138

139139
/**

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ const ProxyRewrite: React.FC<RouteModule.Step1PassProps> = ({ form, disabled })
100100
label={formatMessage({ id: 'page.route.form.itemLabel.template' })}
101101
name={field.name}
102102
key={field.name}
103-
rules={[
104-
{
105-
required: true,
106-
message: `${formatMessage({
107-
id: 'component.global.pleaseEnter',
108-
})} ${formatMessage({ id: 'page.route.form.itemLabel.template' })}`,
109-
},
110-
]}
111103
>
112104
<Input
113105
placeholder={`${formatMessage({
@@ -206,6 +198,7 @@ const ProxyRewrite: React.FC<RouteModule.Step1PassProps> = ({ form, disabled })
206198
{
207199
value: URI_REWRITE_TYPE.REGEXP,
208200
label: formatMessage({ id: 'page.route.radio.regex' }),
201+
dataCypress: 'uri-regex',
209202
},
210203
];
211204

web/src/pages/SSL/typing.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ declare namespace SSLModule {
5252
snis: string[];
5353
status: number;
5454
update_time: number;
55-
validity_start: number;
56-
validity_end: number;
55+
validity_start?: number;
56+
validity_end?: number;
5757
};
5858
}

0 commit comments

Comments
 (0)