Skip to content

Commit

Permalink
Merge branch 'master' into rm/sysv
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed Oct 29, 2020
2 parents 68dd0fe + 2d49dea commit 9a9f5df
Show file tree
Hide file tree
Showing 117 changed files with 1,977 additions and 672 deletions.
2 changes: 2 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ last 2 Chrome versions
last 2 Safari versions
> 0.25%
not ie 11
not op_mini all
not samsung 4

[dev]
last 1 chrome versions
Expand Down
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/v8_breaking_change.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ assignees: ''

---

<!--
****************************************
******* LABEL CHANGES NECESSARY ********
****************************************
Please add a "NeededFor:${TeamName}" label to denote the team that is
requesting the breaking change is surfaced in the Upgrade Assistant.
-->

## Change description

**Which release will ship the breaking change?**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export declare class KibanaRequest<Params = unknown, Query = unknown, Body = unk
| [isSystemRequest](./kibana-plugin-core-server.kibanarequest.issystemrequest.md) | | <code>boolean</code> | Whether or not the request is a "system request" rather than an application-level request. Can be set on the client using the <code>HttpFetchOptions#asSystemRequest</code> option. |
| [params](./kibana-plugin-core-server.kibanarequest.params.md) | | <code>Params</code> | |
| [query](./kibana-plugin-core-server.kibanarequest.query.md) | | <code>Query</code> | |
| [rewrittenUrl](./kibana-plugin-core-server.kibanarequest.rewrittenurl.md) | | <code>Url</code> | URL rewritten in onPreRouting request interceptor. |
| [rewrittenUrl](./kibana-plugin-core-server.kibanarequest.rewrittenurl.md) | | <code>URL</code> | URL rewritten in onPreRouting request interceptor. |
| [route](./kibana-plugin-core-server.kibanarequest.route.md) | | <code>RecursiveReadonly&lt;KibanaRequestRoute&lt;Method&gt;&gt;</code> | matched route details |
| [socket](./kibana-plugin-core-server.kibanarequest.socket.md) | | <code>IKibanaSocket</code> | [IKibanaSocket](./kibana-plugin-core-server.ikibanasocket.md) |
| [url](./kibana-plugin-core-server.kibanarequest.url.md) | | <code>Url</code> | a WHATWG URL standard object. |
| [url](./kibana-plugin-core-server.kibanarequest.url.md) | | <code>URL</code> | a WHATWG URL standard object. |
| [uuid](./kibana-plugin-core-server.kibanarequest.uuid.md) | | <code>string</code> | A UUID to identify this request. |

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ URL rewritten in onPreRouting request interceptor.
<b>Signature:</b>

```typescript
readonly rewrittenUrl?: Url;
readonly rewrittenUrl?: URL;
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ a WHATWG URL standard object.
<b>Signature:</b>

```typescript
readonly url: Url;
readonly url: URL;
```

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 17 additions & 11 deletions src/core/server/http/http_server.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { parse as parseUrl } from 'url';
import { Request } from 'hapi';
import { merge } from 'lodash';
import { Socket } from 'net';
Expand Down Expand Up @@ -72,6 +73,7 @@ function createKibanaRequestMock<P = any, Q = any, B = any>({
auth = { isAuthenticated: true },
}: RequestFixtureOptions<P, Q, B> = {}) {
const queryString = stringify(query, { sort: false });
const url = parseUrl(`${path}${queryString ? `?${queryString}` : ''}`);

return KibanaRequest.from<P, Q, B>(
createRawRequestMock({
Expand All @@ -83,12 +85,7 @@ function createKibanaRequestMock<P = any, Q = any, B = any>({
payload: body,
path,
method,
url: {
path,
pathname: path,
query: queryString,
search: queryString ? `?${queryString}` : queryString,
},
url,
route: {
settings: { tags: routeTags, auth: routeAuthRequired, app: kibanaRouteOptions },
},
Expand Down Expand Up @@ -121,6 +118,11 @@ interface DeepPartialArray<T> extends Array<DeepPartial<T>> {}
type DeepPartialObject<T> = { [P in keyof T]+?: DeepPartial<T[P]> };

function createRawRequestMock(customization: DeepPartial<Request> = {}) {
const pathname = customization.url?.pathname || '/';
const path = `${pathname}${customization.url?.search || ''}`;
const url = Object.assign({ pathname, path, href: path }, customization.url);

// @ts-expect-error _core isn't supposed to be accessed - remove once we upgrade to hapi v18
return merge(
{},
{
Expand All @@ -129,17 +131,21 @@ function createRawRequestMock(customization: DeepPartial<Request> = {}) {
isAuthenticated: true,
},
headers: {},
path: '/',
path,
route: { settings: {} },
url: {
href: '/',
},
url,
raw: {
req: {
url: '/',
url: path,
socket: {},
},
},
// TODO: Remove once we upgrade to hapi v18
_core: {
info: {
uri: 'http://localhost',
},
},
},
customization
) as Request;
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/http_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export class HttpServer {
}

this.registerOnPreRouting((request, response, toolkit) => {
const oldUrl = request.url.href!;
const oldUrl = request.url.pathname + request.url.search;
const newURL = basePathService.remove(oldUrl);
const shouldRedirect = newURL !== oldUrl;
if (shouldRedirect) {
Expand Down
24 changes: 21 additions & 3 deletions src/core/server/http/integration_tests/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ describe('OnPreRouting', () => {
const router = createRouter('/');

router.get({ path: '/login', validate: false }, (context, req, res) => {
return res.ok({ body: { rewrittenUrl: req.rewrittenUrl?.path } });
return res.ok({
body: {
rewrittenUrl: req.rewrittenUrl
? `${req.rewrittenUrl.pathname}${req.rewrittenUrl.search}`
: undefined,
},
});
});

registerOnPreRouting((req, res, t) => t.rewriteUrl('/login'));
Expand All @@ -143,7 +149,13 @@ describe('OnPreRouting', () => {
const router = createRouter('/');

router.get({ path: '/reroute-2', validate: false }, (context, req, res) => {
return res.ok({ body: { rewrittenUrl: req.rewrittenUrl?.path } });
return res.ok({
body: {
rewrittenUrl: req.rewrittenUrl
? `${req.rewrittenUrl.pathname}${req.rewrittenUrl.search}`
: undefined,
},
});
});

registerOnPreRouting((req, res, t) => t.rewriteUrl('/reroute-1'));
Expand All @@ -163,7 +175,13 @@ describe('OnPreRouting', () => {
const router = createRouter('/');

router.get({ path: '/login', validate: false }, (context, req, res) => {
return res.ok({ body: { rewrittenUrl: req.rewrittenUrl?.path } });
return res.ok({
body: {
rewrittenUrl: req.rewrittenUrl
? `${req.rewrittenUrl.pathname}${req.rewrittenUrl.search}`
: undefined,
},
});
});

registerOnPreRouting((req, res, t) => t.next());
Expand Down
Loading

0 comments on commit 9a9f5df

Please sign in to comment.