Added some tests

This commit is contained in:
2021-06-23 22:30:45 +02:00
parent 24f897e907
commit 3d3d7fae48
3796 changed files with 218744 additions and 3 deletions

22
tests/node_modules/resolve-alpn/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2018 Szymon Marczak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

53
tests/node_modules/resolve-alpn/README.md generated vendored Normal file
View File

@@ -0,0 +1,53 @@
# `resolve-alpn`
[![Node CI](https://github.com/szmarczak/resolve-alpn/workflows/Node%20CI/badge.svg)](https://github.com/szmarczak/resolve-alpn/actions)
[![codecov](https://codecov.io/gh/szmarczak/resolve-alpn/branch/master/graph/badge.svg)](https://codecov.io/gh/szmarczak/resolve-alpn)
## API
### resolveALPN(options)
Returns an object with an `alpnProtocol` property. The `socket` property may be also present.
```js
const result = await resolveALPN({
host: 'nghttp2.org',
port: 443,
ALPNProtocols: ['h2', 'http/1.1'],
servername: 'nghttp2.org'
});
console.log(result); // {alpnProtocol: 'h2'}
```
**Note:** While the `servername` option is not required in this case, many other servers do. It's best practice to set it anyway.
**Note:** If the socket times out, the promise will resolve and `result.timeout` will be set to `true`.
#### options
Same as [TLS options](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback).
##### options.resolveSocket
By default, the socket gets destroyed and the promise resolves.<br>
If you set this to true, it will return the socket in a `socket` property.
```js
const result = await resolveALPN({
host: 'nghttp2.org',
port: 443,
ALPNProtocols: ['h2', 'http/1.1'],
servername: 'nghttp2.org',
resolveSocket: true
});
console.log(result); // {alpnProtocol: 'h2', socket: tls.TLSSocket}
// Remember to destroy the socket if you don't use it!
result.socket.destroy();
```
## License
MIT

33
tests/node_modules/resolve-alpn/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
const tls = require('tls');
module.exports = (options = {}) => new Promise((resolve, reject) => {
let timeout = false;
const callback = async () => {
socket.off('timeout', onTimeout);
socket.off('error', reject);
if (options.resolveSocket) {
resolve({alpnProtocol: socket.alpnProtocol, socket, timeout});
if (timeout) {
await Promise.resolve();
socket.emit('timeout');
}
} else {
socket.destroy();
resolve({alpnProtocol: socket.alpnProtocol, timeout});
}
};
const onTimeout = async () => {
timeout = true;
callback();
};
const socket = tls.connect(options, callback);
socket.on('error', reject);
socket.once('timeout', onTimeout);
});

61
tests/node_modules/resolve-alpn/package.json generated vendored Normal file
View File

@@ -0,0 +1,61 @@
{
"_from": "resolve-alpn@^1.0.0",
"_id": "resolve-alpn@1.1.2",
"_inBundle": false,
"_integrity": "sha512-8OyfzhAtA32LVUsJSke3auIyINcwdh5l3cvYKdKO0nvsYSKuiLfTM5i78PJswFPT8y6cPW+L1v6/hE95chcpDA==",
"_location": "/resolve-alpn",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "resolve-alpn@^1.0.0",
"name": "resolve-alpn",
"escapedName": "resolve-alpn",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/http2-wrapper"
],
"_resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.1.2.tgz",
"_shasum": "30b60cfbb0c0b8dc897940fe13fe255afcdd4d28",
"_spec": "resolve-alpn@^1.0.0",
"_where": "/home/lilleman/go/src/gitlab.larvit.se/power-plan/auth/tests/node_modules/http2-wrapper",
"author": {
"name": "Szymon Marczak"
},
"bugs": {
"url": "https://github.com/szmarczak/resolve-alpn/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Detects the ALPN protocol",
"devDependencies": {
"ava": "^3.15.0",
"nyc": "^15.1.0",
"pem": "1.14.3",
"xo": "^0.38.2"
},
"files": [
"index.js"
],
"homepage": "https://github.com/szmarczak/resolve-alpn#readme",
"keywords": [
"alpn",
"tls",
"socket",
"http2"
],
"license": "MIT",
"main": "index.js",
"name": "resolve-alpn",
"repository": {
"type": "git",
"url": "git+https://github.com/szmarczak/resolve-alpn.git"
},
"scripts": {
"test": "xo && nyc --reporter=lcovonly --reporter=text --reporter=html ava"
},
"version": "1.1.2"
}