Skip to content

Commit 1fe7ca4

Browse files
Merge pull request #6 from gemini-testing/rebranding
chore: hermione -> testplane
2 parents 1d299e3 + 6c25963 commit 1fe7ca4

8 files changed

Lines changed: 3849 additions & 1388 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [12.x, 14.x]
15+
node-version: [14.x, 16.x, 18.x, 20.x]
1616

1717
steps:
1818
- uses: actions/checkout@v2

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# hermione-oauth
1+
# @testplane/oauth
22

33
Some Remote WebDriver Servers requires OAuth authorization for each request. This plugin is useful for setting of authorization header with OAuth token.
44

55
## Install
66

77
```bash
8-
npm install hermione-oauth --save-dev
8+
npm install @testplane/oauth --save-dev
99
```
1010

1111
## Usage
1212

1313
```js
14-
// .hermione.conf.js
14+
// .testplane.conf.js
1515
module.exports = {
1616
// ...
1717
plugins: {
18-
"hermione-oauth": {
18+
"@testplane/oauth": {
1919
enabled: true, // plugin is enabled by default
2020
token: "<token>", // option also accepts absolute filepath with a token
2121
help: "https://...", // information on where to get a token
@@ -25,5 +25,5 @@ module.exports = {
2525
```
2626

2727
Each plugin option can be redefined by
28-
- environment variable which starts with prefix `hermione_oauth_`, for example, `hermione_oauth_token=123-456-789`
28+
- environment variable which starts with prefix `testplane_oauth_`, for example, `testplane_oauth_token=123-456-789`
2929
- CLI option which starts with prefix `--oauth-`, for example, `--oauth-token=123-456-789`

package-lock.json

Lines changed: 3801 additions & 1342 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "hermione-oauth",
3-
"version": "2.0.0",
2+
"name": "@testplane/oauth",
3+
"version": "0.0.1",
44
"description": "Plugin for convenient setting of authorization header with OAuth token",
55
"main": "build/index.js",
66
"files": [
@@ -21,39 +21,38 @@
2121
},
2222
"repository": {
2323
"type": "git",
24-
"url": "git+https://github.com/gemini-testing/hermione-oauth.git"
24+
"url": "git+https://github.com/gemini-testing/testplane-oauth.git"
2525
},
2626
"engines": {
2727
"node": ">= 12.0.0"
2828
},
2929
"keywords": [
30+
"testplane",
3031
"hermione",
32+
"plugin",
3133
"oauth"
3234
],
3335
"license": "UNLICENSED",
3436
"bugs": {
35-
"url": "https://github.com/gemini-testing/hermione-oauth/issues"
37+
"url": "https://github.com/gemini-testing/testplane-oauth/issues"
3638
},
37-
"homepage": "https://github.com/gemini-testing/hermione-oauth#readme",
39+
"homepage": "https://github.com/gemini-testing/testplane-oauth#readme",
3840
"devDependencies": {
3941
"@types/jest": "28.1.3",
4042
"@types/node": "12.20.55",
4143
"@typescript-eslint/eslint-plugin": "5.30.0",
4244
"@typescript-eslint/parser": "5.30.0",
4345
"eslint": "8.18.0",
4446
"eslint-config-gemini-testing": "3.0.0",
45-
"hermione": "5.0.1",
4647
"jest": "28.1.1",
4748
"jest-extended": "2.0.0",
4849
"prettier": "2.7.1",
4950
"rimraf": "3.0.2",
51+
"testplane": "0.1.0-rc.0",
5052
"ts-jest": "28.0.5",
5153
"typescript": "4.7.4"
5254
},
5355
"dependencies": {
5456
"gemini-configparser": "1.3.0"
55-
},
56-
"peerDependencies": {
57-
"hermione": ">=3.13.0"
5857
}
5958
}

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function parseConfig(options: Record<string, unknown>): PluginConfig {
4949
}),
5050
help: nonEmptyString("help"),
5151
}),
52-
{ envPrefix: "hermione_oauth_", cliPrefix: "--oauth-" },
52+
{ envPrefix: "testplane_oauth_", cliPrefix: "--oauth-" },
5353
);
5454

5555
return parseOptions({ options, env, argv });

src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class PluginError extends Error {
22
constructor(message: string) {
3-
super(`hermione-oauth: ${message}`);
3+
super(`@testplane/oauth: ${message}`);
44
}
55
}
66

src/index.test.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,68 @@
11
import { EventEmitter } from "events";
22

3-
import type Hermione from "hermione";
3+
import type Testplane from "testplane";
4+
import type { Config } from "testplane";
45

56
import plugin from "./";
67
import * as readToken from "./read-token";
78

9+
type BrowserConfig = Config["browsers"][string];
10+
811
jest.mock("./config", () => ({ parseConfig: jest.fn(opts => opts) }));
912

1013
jest.mock("./read-token");
1114
const readTokenMock = readToken as jest.Mocked<typeof readToken>;
1215

13-
describe("hermione-oauth", () => {
14-
const browser = (config: object = {}): Hermione.BrowserConfig => config as unknown as Hermione.BrowserConfig;
16+
describe("@testplane/oauth", () => {
17+
const browser = (config: object = {}): BrowserConfig => config as unknown as BrowserConfig;
1518

16-
const hermioneMock = (browsers: Record<string, Hermione.BrowserConfig>): Hermione => {
17-
const emitter = new EventEmitter() as unknown as Hermione;
19+
const testplaneMock = (browsers: Record<string, BrowserConfig>): Testplane => {
20+
const emitter = new EventEmitter() as any;
1821

19-
emitter.events = { BEGIN: "begin" } as Hermione.EVENTS;
22+
emitter.events = { BEGIN: "begin" }
2023
emitter.config = {
2124
forBrowser: (id: string) => browsers[id],
2225
getBrowserIds: () => Object.keys(browsers),
23-
} as Hermione.Config;
26+
} as Config;
2427

2528
return emitter;
2629
};
2730

2831
test("should do nothing if plugin is disabled", () => {
2932
const config = { headers: { "<foo>": "<bar>" } };
30-
const hermione = hermioneMock({ "<bro-id>": browser(config) });
33+
const testplane = testplaneMock({ "<bro-id>": browser(config) });
3134

32-
plugin(hermione, { enabled: false });
33-
hermione.emit(hermione.events.BEGIN);
35+
plugin(testplane, { enabled: false });
36+
testplane.emit(testplane.events.BEGIN);
3437

3538
expect(config).toEqual({ headers: { "<foo>": "<bar>" } });
3639
});
3740

3841
test("should set token for each browser config", () => {
3942
const [config1, config2] = [{ headers: { "<foo>": "<bar>" } }, { headers: { "<baz>": "<quux>" } }];
40-
const hermione = hermioneMock({ "<bro1-id>": browser(config1), "<bro2-id>": browser(config2) });
43+
const testplane = testplaneMock({ "<bro1-id>": browser(config1), "<bro2-id>": browser(config2) });
4144

42-
plugin(hermione, { enabled: true, token: "123456789" });
43-
hermione.emit(hermione.events.BEGIN);
45+
plugin(testplane, { enabled: true, token: "123456789" });
46+
testplane.emit(testplane.events.BEGIN);
4447

4548
expect(config1).toEqual({ headers: { "<foo>": "<bar>", Authorization: "OAuth 123456789" } });
4649
expect(config2).toEqual({ headers: { "<baz>": "<quux>", Authorization: "OAuth 123456789" } });
4750
});
4851

4952
test("should not set token if authorization header is already set", () => {
5053
const config = { headers: { Authorization: "<foo>" } };
51-
const hermione = hermioneMock({ "<bro-id>": browser(config) });
54+
const testplane = testplaneMock({ "<bro-id>": browser(config) });
5255

53-
plugin(hermione, { enabled: true, token: "123456789" });
54-
hermione.emit(hermione.events.BEGIN);
56+
plugin(testplane, { enabled: true, token: "123456789" });
57+
testplane.emit(testplane.events.BEGIN);
5558

5659
expect(config).toEqual({ headers: { Authorization: "<foo>" } });
5760
});
5861

5962
test("should read token from file when it is given as absolute path", () => {
60-
const hermione = hermioneMock({ "<bro-id>": browser() });
63+
const testplane = testplaneMock({ "<bro-id>": browser() });
6164

62-
plugin(hermione, { enabled: true, token: "/foo/bar", help: "https://<help>" });
65+
plugin(testplane, { enabled: true, token: "/foo/bar", help: "https://<help>" });
6366

6467
expect(readTokenMock.default).toHaveBeenCalledTimes(1);
6568
expect(readTokenMock.default).toHaveBeenCalledWith("/foo/bar", "https://<help>");
@@ -69,10 +72,10 @@ describe("hermione-oauth", () => {
6972
readTokenMock.default.mockReturnValue("987654321");
7073

7174
const [config1, config2] = [{ headers: { "<foo>": "<bar>" } }, { headers: { "<baz>": "<quux>" } }];
72-
const hermione = hermioneMock({ "<bro1-id>": browser(config1), "<bro2-id>": browser(config2) });
75+
const testplane = testplaneMock({ "<bro1-id>": browser(config1), "<bro2-id>": browser(config2) });
7376

74-
plugin(hermione, { enabled: true, token: "/foo/bar" });
75-
hermione.emit(hermione.events.BEGIN);
77+
plugin(testplane, { enabled: true, token: "/foo/bar" });
78+
testplane.emit(testplane.events.BEGIN);
7679

7780
expect(config1).toEqual({ headers: { "<foo>": "<bar>", Authorization: "OAuth 987654321" } });
7881
expect(config2).toEqual({ headers: { "<baz>": "<quux>", Authorization: "OAuth 987654321" } });
@@ -82,11 +85,11 @@ describe("hermione-oauth", () => {
8285
readTokenMock.default.mockReturnValue("987654321");
8386

8487
const config = { headers: { Authorization: "<foo>" } };
85-
const hermione = hermioneMock({ "<bro-id>": browser(config) });
88+
const testplane = testplaneMock({ "<bro-id>": browser(config) });
8689

87-
plugin(hermione, { enabled: true, token: "/foo/bar" });
90+
plugin(testplane, { enabled: true, token: "/foo/bar" });
8891

89-
hermione.emit(hermione.events.BEGIN);
92+
testplane.emit(testplane.events.BEGIN);
9093

9194
expect(config).toEqual({ headers: { Authorization: "<foo>" } });
9295
});

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import path from "path";
22

3-
import type Hermione from "hermione";
3+
import type Testplane from "testplane";
44

55
import { parseConfig } from "./config";
66
import readToken from "./read-token";
77

8-
export = (hermione: Hermione, options: Record<string, unknown>): void => {
8+
export = (testplane: Testplane, options: Record<string, unknown>): void => {
99
const config = parseConfig(options);
1010

1111
if (!config.enabled) {
@@ -14,9 +14,9 @@ export = (hermione: Hermione, options: Record<string, unknown>): void => {
1414

1515
const token = path.isAbsolute(config.token) ? readToken(config.token, config.help) : config.token;
1616

17-
hermione.on(hermione.events.BEGIN, () => {
18-
hermione.config.getBrowserIds().forEach(browserId => {
19-
const browserConfig = hermione.config.forBrowser(browserId);
17+
testplane.on(testplane.events.BEGIN, () => {
18+
testplane.config.getBrowserIds().forEach(browserId => {
19+
const browserConfig = testplane.config.forBrowser(browserId);
2020

2121
browserConfig.headers = { Authorization: `OAuth ${token}`, ...browserConfig.headers };
2222
});

0 commit comments

Comments
 (0)