Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump dependencies #109

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .estlintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ env:
extends:
- "eslint:recommended"
- "plugin:@typescript-eslint/eslint-recommended"
- "plugin:@typescript-eslint/recommended-requiring-type-checking"
- "plugin:@typescript-eslint/recommended"
- "plugin:@typescript-eslint/recommended-type-checked"
- "plugin:@typescript-eslint/stylistic-type-checked"
- "plugin:import/recommended"
- "plugin:import/typescript"
- "plugin:jsdoc/recommended"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- id: is_release_branch_without_pr
name: Find matching PR
uses: actions/github-script@v3
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -42,7 +42,7 @@ jobs:
name: Create Release Pull Request
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Parse release version
id: get_version
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ name: Release SDK if needed

on:
pull_request:
branches: main
types: closed
branches:
- main
types:
- closed

jobs:
release:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && contains(github.event.pull_request.head.ref, 'release/')
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- name: Publish to npm
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Test with Node.js Latest LTS
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
# Latest LTS version
node-version: '12.x'
node-version: '20.x'
- name: Cache NPM modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -25,6 +25,6 @@ jobs:
- name: Run tests
run: npm install && npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
directory: ./coverage/
10 changes: 5 additions & 5 deletions .github/workflows/test-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
lintAndTestWithCoverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Test with Node.js Latest LTS
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
# Latest LTS version
node-version: '12.x'
node-version: '20.x'
- name: Cache NPM modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -25,6 +25,6 @@ jobs:
- run: npm run lint
- run: npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
directory: ./coverage/
3 changes: 2 additions & 1 deletion __test__/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ jest.mock("../src/lib/client", () => ({
}));

test("Assert Token and Server URL are required", () => {
// @ts-ignore
dustin-ruetz marked this conversation as resolved.
Show resolved Hide resolved
expect(() => new RequestAdapter(new HTTPClient(), {serverURL: undefined, token: undefined}))
.toThrowError("Options serverURL and token are required.");
.toThrow("Options serverURL and token are required.");
});

describe("Assert Adapter delegates calls to Client", () => {
Expand Down
16 changes: 8 additions & 8 deletions __test__/itembuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ describe("Test ItemBuilder", () => {
.build();

const { urls } = newItem;
expect(urls.length).toEqual(2);
expect(urls?.length).toEqual(2);

// Assert:
// - the **LAST** url to be set as "primary" is given that attribute
// - there is only 1 url with the `primary: true` attr
let primaryUrls = 0;
let primaryUrl;
urls.forEach((url) => {
urls?.forEach((url) => {
if (url.primary) {
primaryUrl = url.href;
primaryUrls++;
Expand Down Expand Up @@ -92,7 +92,7 @@ describe("Test ItemBuilder", () => {
// Invalid category -> ERROR
expect(() => {
builder.setCategory("invalid");
}).toThrowError(TypeError);
}).toThrow(TypeError);

builder.setCategory(CategoryEnum.Login);
const itemWithCategory = builder.build();
Expand All @@ -106,7 +106,7 @@ describe("Test ItemBuilder", () => {
.addSection("section 1")
.build();

expect(itemOneSection.sections.length).toEqual(1);
expect(itemOneSection.sections?.length).toEqual(1);
expect(isValidSectionId(itemOneSection.sections[0].id)).toBeTruthy();
});

Expand Down Expand Up @@ -213,7 +213,7 @@ describe("Test ItemBuilder", () => {
});

describe("Field GeneratorRecipe Configuration", () => {
// @ts-expect-error
// @ts-ignore
const invalidRecipe: GeneratorRecipe = {
length: 6,
characterSets: new Array("adfioadhfg"),
Expand Down Expand Up @@ -268,7 +268,7 @@ describe("Test ItemBuilder", () => {
generate: true,
recipe: invalidRecipe,
});
}).toThrowError();
}).toThrow();
});

it("does not throw invalid recipe error if generate = false", () => {
Expand All @@ -279,7 +279,7 @@ describe("Test ItemBuilder", () => {
generate: false,
recipe: invalidRecipe,
});
}).not.toThrowError();
}).not.toThrow();

const item = builder.build();
expect(item.fields.length).toEqual(1);
Expand Down Expand Up @@ -342,6 +342,6 @@ describe("Use ENV Vars as default values", () => {
const builder = new ItemBuilder();
expect(() => {
builder.build();
}).toThrowError();
}).toThrow();
});
});
46 changes: 27 additions & 19 deletions __test__/op-connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe("Test OnePasswordConnect CRUD", () => {

expect(updatedItem instanceof FullItem).toEqual(true);
expect(updatedItem.title).toBe("Updated Title");
expect(updatedItem.tags.sort()).toEqual(itemToBeUpdated.tags.sort());
expect(updatedItem.tags?.sort()).toEqual(itemToBeUpdated.tags.sort());
});

test("get item by title", async () => {
Expand Down Expand Up @@ -175,8 +175,9 @@ describe("Test OnePasswordConnect CRUD", () => {
[null],
[""],
])("should throw error if %s provided", async (vaultQuery) => {
// @ts-ignore
await expect(() => op.getVault(vaultQuery))
.rejects.toThrowError(ERROR_MESSAGE.PROVIDE_VAULT_NAME_OR_ID);
.rejects.toThrow(ERROR_MESSAGE.PROVIDE_VAULT_NAME_OR_ID);
});

test("should return vault by id", async () => {
Expand Down Expand Up @@ -218,7 +219,7 @@ describe("Test OnePasswordConnect CRUD", () => {
});

test("should re-throw api error", async () => {
const badRequestError = { status: 400, message: "Some bad request" };
const badRequestError = new Error('Some bad request');

getItemsByTitleMock(title).replyWithError(badRequestError);

Expand All @@ -230,8 +231,8 @@ describe("Test OnePasswordConnect CRUD", () => {
const item2 = { id: "2" } as Item;

getItemsByTitleMock(title).reply(200, [item1, item2]);
getFullItemMock(item1.id).reply(200, item1);
getFullItemMock(item2.id).reply(200, item2);
getFullItemMock(item1.id!).reply(200, item1);
getFullItemMock(item2.id!).reply(200, item2);

const result: FullItem[] = await op.listItemsByTitle(VAULT_ID, title);

Expand All @@ -247,8 +248,9 @@ describe("Test OnePasswordConnect CRUD", () => {
[null],
[""],
])("should throw error if %s provided", async (itemQuery) => {
// @ts-ignore
await expect(() => op.getItem(VAULT_ID, itemQuery))
.rejects.toThrowError(ERROR_MESSAGE.PROVIDE_ITEM_NAME_OR_ID);
.rejects.toThrow(ERROR_MESSAGE.PROVIDE_ITEM_NAME_OR_ID);
});

test("should return item by id", async () => {
Expand Down Expand Up @@ -286,7 +288,7 @@ describe("Test OnePasswordConnect CRUD", () => {
});

test("should re-throw api error", async () => {
const notFoundError = { status: 404, message: "Item not found" };
const notFoundError = new Error('Item not found');

apiMock.getItemById()
.replyWithError(notFoundError);
Expand Down Expand Up @@ -336,7 +338,7 @@ describe("Test OnePasswordConnect CRUD", () => {
.reply(404);

await expect(() => op.deleteItemById(VAULT_ID, ITEM_ID))
.rejects.toThrowError();
.rejects.toThrow();
});

test("should finish successfully ", async () => {
Expand All @@ -351,8 +353,9 @@ describe("Test OnePasswordConnect CRUD", () => {
[null],
[""],
])("should throw error if %s provided", async (itemQuery) => {
// @ts-ignore
await expect(() => op.deleteItem(VAULT_ID, itemQuery))
.rejects.toThrowError(ERROR_MESSAGE.PROVIDE_ITEM_NAME_OR_ID);
.rejects.toThrow(ERROR_MESSAGE.PROVIDE_ITEM_NAME_OR_ID);
});

test("should throw an error if 2 items found by title", async () => {
Expand Down Expand Up @@ -425,14 +428,14 @@ describe("Test OnePasswordConnect CRUD", () => {
apiMock.getItemById().reply(404);

await expect(() => op.getItemOTP(VAULT_ID, ITEM_ID))
.rejects.toThrowError();
.rejects.toThrow();
});

test("should throw error if item has no OTP", async () => {
apiMock.getItemById().reply(200, { id: ITEM_ID });

await expect(() => op.getItemOTP(VAULT_ID, ITEM_ID))
.rejects.toThrowError(ErrorMessageFactory.noOTPFoundForItem(ITEM_ID));
.rejects.toThrow(ErrorMessageFactory.noOTPFoundForItem(ITEM_ID));
});

test("should return OTP", async () => {
Expand All @@ -455,7 +458,7 @@ describe("Test OnePasswordConnect CRUD", () => {
});

test("should re-throw api error", async () => {
const badRequestError = { status: 400, message: "Some bad request" };
const badRequestError = new Error('Some bad request');

apiMock.listItemsByTitleContains(title).replyWithError(badRequestError);

Expand All @@ -482,7 +485,8 @@ describe("Test OnePasswordConnect CRUD", () => {
describe("get file by id", () => {
test.each(["", null, undefined])
("should throw error if %s provides as file id", async (fileId) => {
await expect(() => op.getFileById(vaultTitle, itemTitle, fileId)).rejects.toThrowError(new Error(ErrorMessageFactory.noFileIdProvided()));
// @ts-ignore
await expect(() => op.getFileById(vaultTitle, itemTitle, fileId)).rejects.toThrow(new Error(ErrorMessageFactory.noFileIdProvided()));
});

test("should throw error if invalid vault id provided", async () => {
Expand Down Expand Up @@ -534,7 +538,8 @@ describe("Test OnePasswordConnect CRUD", () => {
describe('as a string', () => {
test.each(["", null, undefined])
("should throw error if %s provides as file id", async (fileId) => {
await expect(() => op.getFileContent(vaultTitle, itemTitle, fileId)).rejects.toThrowError(new Error(ErrorMessageFactory.noFileIdProvided()));
// @ts-ignore
await expect(() => op.getFileContent(vaultTitle, itemTitle, fileId)).rejects.toThrow(new Error(ErrorMessageFactory.noFileIdProvided()));
});

test("should throw error if invalid vault id provided", async () => {
Expand Down Expand Up @@ -583,7 +588,8 @@ describe("Test OnePasswordConnect CRUD", () => {
describe('as a stream', () => {
test.each(["", null, undefined])
("should throw error if %s provides as file id", async (fileId) => {
await expect(() => op.getFileContentStream(vaultTitle, itemTitle, fileId)).rejects.toThrowError(new Error(ErrorMessageFactory.noFileIdProvided()));
// @ts-ignore
await expect(() => op.getFileContentStream(vaultTitle, itemTitle, fileId)).rejects.toThrow(new Error(ErrorMessageFactory.noFileIdProvided()));
});

test("should throw error if invalid vault id provided", async () => {
Expand Down Expand Up @@ -643,10 +649,12 @@ describe("Connector HTTP errors", () => {
});

test("factory requires serverURL and token", () => {

expect(() => OnePasswordConnect({serverURL: undefined, token: undefined})).toThrowError();
expect(() => OnePasswordConnect({serverURL: mockServerUrl, token: undefined})).toThrowError();
expect(() => OnePasswordConnect({serverURL: undefined, token: mockToken})).toThrowError();
// @ts-ignore
expect(() => OnePasswordConnect({serverURL: undefined, token: undefined})).toThrow();
// @ts-ignore
expect(() => OnePasswordConnect({serverURL: mockServerUrl, token: undefined})).toThrow();
// @ts-ignore
expect(() => OnePasswordConnect({serverURL: undefined, token: mockToken})).toThrow();

});

Expand Down
Loading