Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from JupiterOne/6-toMatchGraphObjectSchema
Browse files Browse the repository at this point in the history
Fixes #6 - Update to have example 'toMatchGraphObjectSchema' usage
  • Loading branch information
austinkelleher authored Aug 3, 2020
2 parents f6d9796 + 8036827 commit e8cb1f3
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 30 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
"lint": "eslint . --cache --fix --ext .ts,.tsx",
"format": "prettier --write '**/*.{ts,js,json,css,md,yml}'",
"type-check": "tsc",
"test": "jest --passWithNoTests",
"test": "jest",
"test:ci": "yarn lint && yarn type-check && yarn test",
"build": "tsc -p tsconfig.dist.json --declaration",
"prepush": "yarn lint && yarn type-check && jest --changedSince master",
"prepack": "yarn build"
},
"peerDependencies": {
"@jupiterone/integration-sdk-core": "^2.6.0"
"@jupiterone/integration-sdk-core": "^2.8.0"
},
"devDependencies": {
"@jupiterone/integration-sdk-core": "^2.6.0",
"@jupiterone/integration-sdk-dev-tools": "^2.6.0",
"@jupiterone/integration-sdk-testing": "^2.6.0"
"@jupiterone/integration-sdk-core": "^2.8.0",
"@jupiterone/integration-sdk-dev-tools": "^2.8.0",
"@jupiterone/integration-sdk-testing": "^2.8.0"
}
}
12 changes: 12 additions & 0 deletions src/steps/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Object {
"createdOn": undefined,
"displayName": "Example Co. Acme Account",
"id": "acme-unique-account-id",
"manager": "Manager Name",
"mfaEnabled": true,
"name": "Example Co. Acme Account",
},
Object {
Expand All @@ -40,8 +42,11 @@ Object {
"_type": "acme_user",
"createdOn": undefined,
"displayName": "User One",
"email": "[email protected]",
"firstName": "John",
"id": "acme-user-1",
"name": "User One",
"username": "testusername",
},
Object {
"_class": Array [
Expand All @@ -60,8 +65,11 @@ Object {
"_type": "acme_user",
"createdOn": undefined,
"displayName": "User Two",
"email": "[email protected]",
"firstName": "John",
"id": "acme-user-2",
"name": "User Two",
"username": "testusername",
},
Object {
"_class": Array [
Expand All @@ -85,7 +93,9 @@ Object {
"_type": "acme_group",
"createdOn": undefined,
"displayName": "Group One",
"email": "[email protected]",
"id": "acme-group-1",
"logoLink": "https://test.com/logo.png",
"name": "Group One",
},
],
Expand Down Expand Up @@ -131,5 +141,7 @@ Object {
"acme_account_has_group",
"acme_group_has_user",
],
"numCollectedEntities": 4,
"numCollectedRelationships": 4,
}
`;
9 changes: 9 additions & 0 deletions src/steps/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export async function fetchUsers({
assign: {
_type: 'acme_user',
_class: 'User',
username: 'testusername',
email: '[email protected]',
// This is a custom property that is not a part of the data model class
// hierarchy. See: https://github.com/JupiterOne/data-model/blob/master/src/schemas/User.json
firstName: 'John',
},
},
});
Expand Down Expand Up @@ -58,6 +63,10 @@ export async function fetchGroups({
assign: {
_type: 'acme_group',
_class: 'UserGroup',
email: '[email protected]',
// This is a custom property that is not a part of the data model class
// hierarchy. See: https://github.com/JupiterOne/data-model/blob/master/src/schemas/UserGroup.json
logoLink: 'https://test.com/logo.png',
},
},
});
Expand Down
4 changes: 4 additions & 0 deletions src/steps/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export async function fetchAccountDetails({
_key: 'acme-unique-account-id',
_type: 'acme_account',
_class: 'Account',
mfaEnabled: true,
// This is a custom property that is not a part of the data model class
// hierarchy. See: https://github.com/JupiterOne/data-model/blob/master/src/schemas/Account.json
manager: 'Manager Name',
},
},
});
Expand Down
64 changes: 64 additions & 0 deletions src/steps/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,72 @@ test('should collect data', async () => {

// Review snapshot, failure is a regression
expect({
numCollectedEntities: context.jobState.collectedEntities.length,
numCollectedRelationships: context.jobState.collectedRelationships.length,
collectedEntities: context.jobState.collectedEntities,
collectedRelationships: context.jobState.collectedRelationships,
encounteredTypes: context.jobState.encounteredTypes,
}).toMatchSnapshot();

expect(
context.jobState.collectedEntities.filter((e) =>
e._class.includes('Account'),
),
).toMatchGraphObjectSchema({
_class: ['Account'],
schema: {
additionalProperties: false,
properties: {
_type: { const: 'acme_account' },
manager: { type: 'string' },
_rawData: {
type: 'array',
items: { type: 'object' },
},
},
required: ['manager'],
},
});

expect(
context.jobState.collectedEntities.filter((e) => e._class.includes('User')),
).toMatchGraphObjectSchema({
_class: ['User'],
schema: {
additionalProperties: false,
properties: {
_type: { const: 'acme_user' },
firstName: { type: 'string' },
_rawData: {
type: 'array',
items: { type: 'object' },
},
},
required: ['firstName'],
},
});

expect(
context.jobState.collectedEntities.filter((e) =>
e._class.includes('UserGroup'),
),
).toMatchGraphObjectSchema({
_class: ['UserGroup'],
schema: {
additionalProperties: false,
properties: {
_type: { const: 'acme_group' },
logoLink: {
type: 'string',
// Validate that the `logoLink` property has a URL format
format: 'url',
},
_rawData: {
type: 'array',
items: { type: 'object' },
},
},
required: ['logoLink'],
},
});
});
51 changes: 26 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -464,33 +464,34 @@
dependencies:
ajv "^6.12.0"

"@jupiterone/integration-sdk-cli@^2.6.0":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-cli/-/integration-sdk-cli-2.6.0.tgz#89d003e63340aaa9dad70408272412978b024b43"
integrity sha512-nao7qAnwNMPl4frU1FgT4PrA4wLvnrvoEiMLNELeO7eF9dlcts1wJ76xjvM0CEr5e3Cz9zA1Q7bagtpR+4sYLg==
"@jupiterone/integration-sdk-cli@^2.8.0":
version "2.8.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-cli/-/integration-sdk-cli-2.8.0.tgz#f26f632a2f23bd10747cb9f6bf10c340053d95a8"
integrity sha512-1/u0GlqMAdaLRtHG/XPvKGCNqhVFu2h2bBsm+bhtmYbEjCD3y6eu6n7lpmxR8X/3Pttf1XkKkyQTI//c02LyBQ==
dependencies:
"@jupiterone/integration-sdk-runtime" "^2.6.0"
"@jupiterone/integration-sdk-runtime" "^2.8.0"
commander "^5.0.0"
globby "^11.0.0"
lodash "^4.17.19"
upath "^1.2.0"
vis "^4.21.0-EOL"

"@jupiterone/integration-sdk-core@^2.6.0":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-core/-/integration-sdk-core-2.6.0.tgz#74b59cb95b2b7c0c925a770a8b2541a6cd00a909"
integrity sha512-x1nq9KNwWAK8m4SOiE6WCgStEd1E+MgaQwUnTRRHra1xQ7LP4rcdXc8XPBnmPH5sr1nS+Zy1g8LMCaf+7bV9gw==
"@jupiterone/integration-sdk-core@^2.8.0":
version "2.8.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-core/-/integration-sdk-core-2.8.0.tgz#961b308dc92a2c87597617fe0f976593d3397f56"
integrity sha512-fuM075d/km/g4ZKMSV7ozo/zucR0/BMKAg2RYoKHx5uLwJ2Lo9tjIcvH7cKhTY7ZcfbQZEyXz1qAxfC4eC9srw==
dependencies:
"@jupiterone/data-model" "^0.7.1"
lodash "^4.17.15"
uuid "^7.0.3"

"@jupiterone/integration-sdk-dev-tools@^2.6.0":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-dev-tools/-/integration-sdk-dev-tools-2.6.0.tgz#2b85f6e46f2fbc891007e9df881cc7576292cead"
integrity sha512-boN0TW2zi2WcveZYo/8bcbBnNpkeBLo+po5EblLrbxBm7THXZ8jpdKzmfQAt4FPo7GJY8d1xFTLLuZgWHsrJZw==
"@jupiterone/integration-sdk-dev-tools@^2.8.0":
version "2.8.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-dev-tools/-/integration-sdk-dev-tools-2.8.0.tgz#ca8111848d7865746b1b091247b6963d4d831ffd"
integrity sha512-NksPnlN4XsMHOvgDYW9qhWPth8/Dzorl1tyvwl/c6BCgoNj7ER2imBGqrj1Qyi29MFaZOt1Ni3kanX4dw5tX2Q==
dependencies:
"@jupiterone/integration-sdk-cli" "^2.6.0"
"@jupiterone/integration-sdk-cli" "^2.8.0"
"@jupiterone/integration-sdk-testing" "^2.8.0"
"@types/jest" "^25.2.3"
"@types/node" "^14.0.5"
"@typescript-eslint/eslint-plugin" "^3.0.2"
Expand All @@ -506,12 +507,12 @@
ts-node "^8.10.2"
typescript "^3.9.3"

"@jupiterone/integration-sdk-runtime@^2.6.0":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-runtime/-/integration-sdk-runtime-2.6.0.tgz#d235b357eee5435123ffd4ade43f71c4efdbb2f1"
integrity sha512-mhF7hnkNISfCXiXgfCII30FnXEeG4yQL+UZG3xblhTlDBRAkNGTbwOkTfXBNIhewmA7BRPyou+cICXEpftInRg==
"@jupiterone/integration-sdk-runtime@^2.8.0":
version "2.8.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-runtime/-/integration-sdk-runtime-2.8.0.tgz#b00e2e74e0dc7282325ddf17274325d9b0e59318"
integrity sha512-EgXqVuTst0sOqDH5bfOAFRQgviv3MY3+XJA9WVI+zf9q5lBvJajs3k5CSLkJNHerxjxwzcvwLuYrPMZqVJ64YQ==
dependencies:
"@jupiterone/integration-sdk-core" "^2.6.0"
"@jupiterone/integration-sdk-core" "^2.8.0"
"@lifeomic/alpha" "^1.1.3"
async-sema "^3.1.0"
axios "^0.19.2"
Expand All @@ -529,13 +530,13 @@
rimraf "^3.0.2"
uuid "^7.0.3"

"@jupiterone/integration-sdk-testing@^2.6.0":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-testing/-/integration-sdk-testing-2.6.0.tgz#4ee243d7bd5ca1b65dbaf98f83d3e07c609c9585"
integrity sha512-zwkoiO8HW1X+rCo7mgknhIex6X6ReWODoUIE3P9/DBOc3X/oHzEUrS08IfUITZsy+JgRLpDB3sJJFk1gt1+p5Q==
"@jupiterone/integration-sdk-testing@^2.8.0":
version "2.8.0"
resolved "https://registry.yarnpkg.com/@jupiterone/integration-sdk-testing/-/integration-sdk-testing-2.8.0.tgz#6c1c84d57bc2a9628e093cd617a616c434098146"
integrity sha512-v0vRVJVB3crCxqkLnuxTjry08rM9C/eCUJ4OvcFKN3hTeNnUbBoLYztFbee5ip+KJEFGazH67H4FUmbNjLIJqw==
dependencies:
"@jupiterone/integration-sdk-core" "^2.6.0"
"@jupiterone/integration-sdk-runtime" "^2.6.0"
"@jupiterone/integration-sdk-core" "^2.8.0"
"@jupiterone/integration-sdk-runtime" "^2.8.0"
"@pollyjs/adapter-node-http" "^4.0.4"
"@pollyjs/core" "^4.0.4"
"@pollyjs/persister-fs" "^4.0.4"
Expand Down

0 comments on commit e8cb1f3

Please sign in to comment.