mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: remove SecurityDetails API (#35)
This commit is contained in:
parent
a216063829
commit
653b4b9df3
30
docs/api.md
30
docs/api.md
@ -299,17 +299,10 @@
|
||||
* [response.ok()](#responseok)
|
||||
* [response.remoteAddress()](#responseremoteaddress)
|
||||
* [response.request()](#responserequest)
|
||||
* [response.securityDetails()](#responsesecuritydetails)
|
||||
* [response.status()](#responsestatus)
|
||||
* [response.statusText()](#responsestatustext)
|
||||
* [response.text()](#responsetext)
|
||||
* [response.url()](#responseurl)
|
||||
- [class: SecurityDetails](#class-securitydetails)
|
||||
* [securityDetails.issuer()](#securitydetailsissuer)
|
||||
* [securityDetails.protocol()](#securitydetailsprotocol)
|
||||
* [securityDetails.subjectName()](#securitydetailssubjectname)
|
||||
* [securityDetails.validFrom()](#securitydetailsvalidfrom)
|
||||
* [securityDetails.validTo()](#securitydetailsvalidto)
|
||||
- [class: Target](#class-target)
|
||||
* [target.browser()](#targetbrowser)
|
||||
* [target.browserContext()](#targetbrowsercontext)
|
||||
@ -3802,9 +3795,6 @@ Contains a boolean stating whether the response was successful (status in the ra
|
||||
#### response.request()
|
||||
- returns: <[Request]> A matching [Request] object.
|
||||
|
||||
#### response.securityDetails()
|
||||
- returns: <?[SecurityDetails]> Security details if the response was received over the secure connection, or `null` otherwise.
|
||||
|
||||
#### response.status()
|
||||
- returns: <[number]>
|
||||
|
||||
@ -3823,25 +3813,6 @@ Contains the status text of the response (e.g. usually an "OK" for a success).
|
||||
|
||||
Contains the URL of the response.
|
||||
|
||||
### class: SecurityDetails
|
||||
|
||||
[SecurityDetails] class represents the security details when response was received over the secure connection.
|
||||
|
||||
#### securityDetails.issuer()
|
||||
- returns: <[string]> A string with the name of issuer of the certificate.
|
||||
|
||||
#### securityDetails.protocol()
|
||||
- returns: <[string]> String with the security protocol, eg. "TLS 1.2".
|
||||
|
||||
#### securityDetails.subjectName()
|
||||
- returns: <[string]> Name of the subject to which the certificate was issued to.
|
||||
|
||||
#### securityDetails.validFrom()
|
||||
- returns: <[number]> [UnixTime] stating the start of validity of the certificate.
|
||||
|
||||
#### securityDetails.validTo()
|
||||
- returns: <[number]> [UnixTime] stating the end of validity of the certificate.
|
||||
|
||||
### class: Target
|
||||
|
||||
#### target.browser()
|
||||
@ -4018,7 +3989,6 @@ TimeoutError is emitted whenever certain operations are terminated due to timeou
|
||||
[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise"
|
||||
[Request]: #class-request "Request"
|
||||
[Response]: #class-response "Response"
|
||||
[SecurityDetails]: #class-securitydetails "SecurityDetails"
|
||||
[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable"
|
||||
[Target]: #class-target "Target"
|
||||
[TimeoutError]: #class-timeouterror "TimeoutError"
|
||||
|
@ -37,7 +37,6 @@ export = {
|
||||
Playwright: require('./chromium/Playwright').Playwright,
|
||||
Request: require('./chromium/NetworkManager').Request,
|
||||
Response: require('./chromium/NetworkManager').Response,
|
||||
SecurityDetails: require('./chromium/NetworkManager').SecurityDetails,
|
||||
Target: require('./chromium/Target').Target,
|
||||
TimeoutError: require('./Errors').TimeoutError,
|
||||
Touchscreen: require('./chromium/Input').Touchscreen,
|
||||
@ -65,7 +64,6 @@ export = {
|
||||
Playwright: require('./firefox/Playwright').Playwright,
|
||||
Request: require('./firefox/NetworkManager').Request,
|
||||
Response: require('./firefox/NetworkManager').Response,
|
||||
SecurityDetails: require('./firefox/NetworkManager').SecurityDetails,
|
||||
Target: require('./firefox/Browser').Target,
|
||||
TimeoutError: require('./Errors').TimeoutError,
|
||||
Touchscreen: require('./firefox/Input').Touchscreen,
|
||||
|
@ -441,7 +441,6 @@ export class Response {
|
||||
private _statusText: string;
|
||||
private _url: string;
|
||||
private _headers: {[key: string]: string} = {};
|
||||
private _securityDetails: SecurityDetails;
|
||||
|
||||
constructor(client: CDPSession, request: Request, responsePayload: Protocol.Network.Response) {
|
||||
this._client = client;
|
||||
@ -460,7 +459,6 @@ export class Response {
|
||||
this._url = request.url();
|
||||
for (const key of Object.keys(responsePayload.headers))
|
||||
this._headers[key.toLowerCase()] = responsePayload.headers[key];
|
||||
this._securityDetails = responsePayload.securityDetails ? new SecurityDetails(responsePayload.securityDetails) : null;
|
||||
}
|
||||
|
||||
remoteAddress(): { ip: string; port: number; } {
|
||||
@ -487,10 +485,6 @@ export class Response {
|
||||
return this._headers;
|
||||
}
|
||||
|
||||
securityDetails(): SecurityDetails | null {
|
||||
return this._securityDetails;
|
||||
}
|
||||
|
||||
buffer(): Promise<Buffer> {
|
||||
if (!this._contentPromise) {
|
||||
this._contentPromise = this._bodyLoadedPromise.then(async error => {
|
||||
@ -524,42 +518,6 @@ export class Response {
|
||||
}
|
||||
}
|
||||
|
||||
export class SecurityDetails {
|
||||
private _subjectName: string;
|
||||
private _issuer: string;
|
||||
private _validFrom: number;
|
||||
private _validTo: number;
|
||||
private _protocol: string;
|
||||
|
||||
constructor(securityPayload: Protocol.Network.SecurityDetails) {
|
||||
this._subjectName = securityPayload['subjectName'];
|
||||
this._issuer = securityPayload['issuer'];
|
||||
this._validFrom = securityPayload['validFrom'];
|
||||
this._validTo = securityPayload['validTo'];
|
||||
this._protocol = securityPayload['protocol'];
|
||||
}
|
||||
|
||||
subjectName(): string {
|
||||
return this._subjectName;
|
||||
}
|
||||
|
||||
issuer(): string {
|
||||
return this._issuer;
|
||||
}
|
||||
|
||||
validFrom(): number {
|
||||
return this._validFrom;
|
||||
}
|
||||
|
||||
validTo(): number {
|
||||
return this._validTo;
|
||||
}
|
||||
|
||||
protocol(): string {
|
||||
return this._protocol;
|
||||
}
|
||||
}
|
||||
|
||||
function headersArray(headers: { [s: string]: string; }): { name: string; value: string; }[] {
|
||||
const result = [];
|
||||
for (const name in headers) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {helper, assert, debugError} from '../helper';
|
||||
import {EventEmitter} from 'events';
|
||||
import { EventEmitter } from 'events';
|
||||
import { assert, debugError, helper, RegisteredListener } from '../helper';
|
||||
import { JugglerSession } from './Connection';
|
||||
import { FrameManager } from './FrameManager';
|
||||
|
||||
@ -12,10 +12,11 @@ export const NetworkManagerEvents = {
|
||||
|
||||
export class NetworkManager extends EventEmitter {
|
||||
private _session: JugglerSession;
|
||||
private _requests: Map<any, any>;
|
||||
private _requests: Map<string, Request>;
|
||||
private _frameManager: FrameManager;
|
||||
private _eventListeners: any[];
|
||||
constructor(session) {
|
||||
private _eventListeners: RegisteredListener[];
|
||||
|
||||
constructor(session: JugglerSession) {
|
||||
super();
|
||||
this._session = session;
|
||||
|
||||
@ -130,22 +131,21 @@ const causeToResourceType = {
|
||||
};
|
||||
|
||||
export class Request {
|
||||
_id(_id: any, request: Request) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
_session: any;
|
||||
_frame: any;
|
||||
_id: string;
|
||||
private _session: any;
|
||||
private _frame: any;
|
||||
_redirectChain: any;
|
||||
_url: any;
|
||||
_postData: any;
|
||||
_suspended: any;
|
||||
private _url: any;
|
||||
private _postData: any;
|
||||
private _suspended: any;
|
||||
_response: any;
|
||||
_errorText: any;
|
||||
_isNavigationRequest: any;
|
||||
_method: any;
|
||||
_resourceType: any;
|
||||
_headers: {};
|
||||
_interceptionHandled: boolean;
|
||||
private _isNavigationRequest: any;
|
||||
private _method: any;
|
||||
private _resourceType: any;
|
||||
private _headers: {};
|
||||
private _interceptionHandled: boolean;
|
||||
|
||||
constructor(session, frame, redirectChain, payload) {
|
||||
this._session = session;
|
||||
this._frame = frame;
|
||||
@ -236,17 +236,17 @@ export class Request {
|
||||
}
|
||||
|
||||
export class Response {
|
||||
_session: any;
|
||||
_request: any;
|
||||
_remoteIPAddress: any;
|
||||
_remotePort: any;
|
||||
_status: any;
|
||||
_statusText: any;
|
||||
_headers: {};
|
||||
_securityDetails: SecurityDetails;
|
||||
_bodyLoadedPromise: Promise<unknown>;
|
||||
_bodyLoadedPromiseFulfill: (value?: unknown) => void;
|
||||
_contentPromise: any;
|
||||
private _session: any;
|
||||
private _request: any;
|
||||
private _remoteIPAddress: any;
|
||||
private _remotePort: any;
|
||||
private _status: any;
|
||||
private _statusText: any;
|
||||
private _headers: {};
|
||||
private _bodyLoadedPromise: Promise<unknown>;
|
||||
private _bodyLoadedPromiseFulfill: (value?: unknown) => void;
|
||||
private _contentPromise: any;
|
||||
|
||||
constructor(session, request, payload) {
|
||||
this._session = session;
|
||||
this._request = request;
|
||||
@ -255,7 +255,6 @@ export class Response {
|
||||
this._status = payload.status;
|
||||
this._statusText = payload.statusText;
|
||||
this._headers = {};
|
||||
this._securityDetails = payload.securityDetails ? new SecurityDetails(payload.securityDetails) : null;
|
||||
for (const {name, value} of payload.headers)
|
||||
this._headers[name.toLowerCase()] = value;
|
||||
this._bodyLoadedPromise = new Promise(fulfill => {
|
||||
@ -289,10 +288,6 @@ export class Response {
|
||||
return JSON.parse(content);
|
||||
}
|
||||
|
||||
securityDetails() {
|
||||
return this._securityDetails;
|
||||
}
|
||||
|
||||
headers() {
|
||||
return {...this._headers};
|
||||
}
|
||||
@ -328,38 +323,3 @@ export class Response {
|
||||
return this._request;
|
||||
}
|
||||
}
|
||||
|
||||
export class SecurityDetails {
|
||||
_subjectName: string;
|
||||
_issuer: string;
|
||||
_validFrom: number;
|
||||
_validTo: number;
|
||||
_protocol: string;
|
||||
constructor(securityPayload: any) {
|
||||
this._subjectName = securityPayload['subjectName'];
|
||||
this._issuer = securityPayload['issuer'];
|
||||
this._validFrom = securityPayload['validFrom'];
|
||||
this._validTo = securityPayload['validTo'];
|
||||
this._protocol = securityPayload['protocol'];
|
||||
}
|
||||
|
||||
subjectName(): string {
|
||||
return this._subjectName;
|
||||
}
|
||||
|
||||
issuer(): string {
|
||||
return this._issuer;
|
||||
}
|
||||
|
||||
validFrom(): number {
|
||||
return this._validFrom;
|
||||
}
|
||||
|
||||
validTo(): number {
|
||||
return this._validTo;
|
||||
}
|
||||
|
||||
protocol(): string {
|
||||
return this._protocol;
|
||||
}
|
||||
}
|
||||
|
@ -36,40 +36,6 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
||||
delete state.page;
|
||||
});
|
||||
|
||||
describe('Response.securityDetails', function() {
|
||||
it('should work', async({page, httpsServer}) => {
|
||||
const [serverRequest, response] = await Promise.all([
|
||||
httpsServer.waitForRequest('/empty.html'),
|
||||
page.goto(httpsServer.EMPTY_PAGE)
|
||||
]);
|
||||
const securityDetails = response.securityDetails();
|
||||
expect(securityDetails.issuer()).toBe('puppeteer-tests');
|
||||
const protocol = serverRequest.socket.getProtocol().replace('v', ' ');
|
||||
expect(securityDetails.protocol()).toBe(protocol);
|
||||
expect(securityDetails.subjectName()).toBe('puppeteer-tests');
|
||||
expect(securityDetails.validFrom()).toBe(1550084863);
|
||||
expect(securityDetails.validTo()).toBe(33086084863);
|
||||
});
|
||||
it('should be |null| for non-secure requests', async({page, server}) => {
|
||||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
expect(response.securityDetails()).toBe(null);
|
||||
});
|
||||
it('Network redirects should report SecurityDetails', async({page, httpsServer}) => {
|
||||
httpsServer.setRedirect('/plzredirect', '/empty.html');
|
||||
const responses = [];
|
||||
page.on('response', response => responses.push(response));
|
||||
const [serverRequest, ] = await Promise.all([
|
||||
httpsServer.waitForRequest('/plzredirect'),
|
||||
page.goto(httpsServer.PREFIX + '/plzredirect')
|
||||
]);
|
||||
expect(responses.length).toBe(2);
|
||||
expect(responses[0].status()).toBe(302);
|
||||
const securityDetails = responses[0].securityDetails();
|
||||
const protocol = serverRequest.socket.getProtocol().replace('v', ' ');
|
||||
expect(securityDetails.protocol()).toBe(protocol);
|
||||
});
|
||||
});
|
||||
|
||||
it('should work', async({page, httpsServer}) => {
|
||||
let error = null;
|
||||
const response = await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e);
|
||||
|
@ -314,9 +314,6 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
||||
]);
|
||||
expect(error).toBe(null);
|
||||
expect(response.ok()).toBe(true);
|
||||
expect(response.securityDetails()).toBeTruthy();
|
||||
const protocol = serverRequest.socket.getProtocol().replace('v', ' ');
|
||||
expect(response.securityDetails().protocol()).toBe(protocol);
|
||||
await page.close();
|
||||
await browser.close();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user