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

Jh test troubleshooting #401

Closed
wants to merge 12 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
token: ${{ secrets.GH_PUSH_TOKEN }}
- uses: actions/setup-node@v2-beta
with:
node-version: '16.10.0'
node-version: '16.20.2'
registry-url: https://registry.npmjs.org/

- name: Set npm credentials
Expand Down
11 changes: 10 additions & 1 deletion lib/LoginStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,16 @@ export class LoginStrategy extends BaseStrategy {
this.revocationVerification,
this.statuslListEntryVerification
);
console.log(`JH: getting verified roles`)
const uniqueRoles = await verifier.getVerifiedRoles();

if (uniqueRoles.length === 0 && this.acceptedRoles.size > 0) {
return done(undefined, null, 'User does not have any roles.');
}
let user: AuthorisedUser;
console.log(`JH: validating roles`)
if (!this.includeAllRoles && this.acceptedRoles.size > 0) {
console.log(`JH: there are some accepted roles`)
const { userRoles, authorisationStatus } =
this.validateAcceptedRoles(uniqueRoles);

Expand All @@ -393,8 +396,14 @@ export class LoginStrategy extends BaseStrategy {
'User either does not have accpeted role credentials or are invalid.'
);
}
console.log(`JH: reached sign: ${this.jwtSecret}`)
console.log(`JH: sign options: ${JSON.stringify(this.jwtSignOptions)}`)
console.log(`JH: signed user: ${JSON.stringify(user)}`)
if (this.jwtSecret) {
return done(undefined, sign(user, this.jwtSecret, this.jwtSignOptions));
console.log(`JH: signing user`)
const signed = sign(user, this.jwtSecret, this.jwtSignOptions)
console.log(`JH: was able to sign`)
return done(undefined, signed);
}
return done(undefined, user);
} catch (err) {
Expand Down
204 changes: 115 additions & 89 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
},
"homepage": "https://github.com/energywebfoundation/passport-did-auth#readme",
"dependencies": {
"@energyweb/credential-governance": "^2.2.1-alpha.319.0",
"@energyweb/onchain-claims": "^2.2.1-alpha.319.0",
"@energyweb/vc-verification": "^2.2.1-alpha.319.0",
"@energyweb/credential-governance": "2.2.1-alpha.321.0",
"@energyweb/onchain-claims": "2.2.1-alpha.321.0",
"@energyweb/vc-verification": "2.2.1-alpha.321.0",
"@ensdomains/ens-contracts": "^0.0.21",
"@ew-did-registry/claims": "0.8.1-alpha.1140.0",
"@ew-did-registry/did": "0.8.1-alpha.1140.0",
Expand All @@ -59,7 +59,7 @@
"ethers": "5.7.2",
"ganache-cli": "6.12.2",
"js-sha3": "0.8.0",
"jsonwebtoken": "9.0.0",
"jsonwebtoken": "9.0.2",
"multiformats": "9.7.0",
"passport": "0.6.0",
"passport-strategy": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion test/ClaimVerifier.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { utils } from 'ethers';
import chai from 'chai';
import { ChildProcess } from 'child_process';

Check warning on line 3 in test/ClaimVerifier.test.ts

View workflow job for this annotation

GitHub Actions / deploy

'ChildProcess' is defined but never used

Check warning on line 3 in test/ClaimVerifier.test.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

test/ClaimVerifier.test.ts#L3

[@typescript-eslint/no-unused-vars] 'ChildProcess' is defined but never used.
import chaiAsPromised from 'chai-as-promised';
import { JWT } from '@ew-did-registry/jwt';
import { abi as erc1056Abi } from './testUtils/ERC1056.json';
Expand Down Expand Up @@ -106,7 +106,7 @@
const validity = 10 * 60 * 1000;
jest.setTimeout(84000);

describe('ClaimVerifier', () => {
describe.skip('ClaimVerifier', () => {
beforeAll(async function () {
provider = new JsonRpcProvider(rpcUrl);
deployer = provider.getSigner(0);
Expand Down Expand Up @@ -1069,7 +1069,7 @@
assert.strictEqual(verifiedRoles.length, 0);
});

const getAdminRoleDefinition = (namespace: string) => {

Check warning on line 1072 in test/ClaimVerifier.test.ts

View workflow job for this annotation

GitHub Actions / deploy

'namespace' is defined but never used

Check warning on line 1072 in test/ClaimVerifier.test.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

test/ClaimVerifier.test.ts#L1072

[@typescript-eslint/no-unused-vars] 'namespace' is defined but never used.
const roleDef: IRoleDefinitionV2 = {
roleName: adminRole,
enrolmentPreconditions: [],
Expand All @@ -1090,7 +1090,7 @@
return Promise.resolve(roleDef);
};

const getManagerRoleDefinition = (namespace: string) => {

Check warning on line 1093 in test/ClaimVerifier.test.ts

View workflow job for this annotation

GitHub Actions / deploy

'namespace' is defined but never used

Check warning on line 1093 in test/ClaimVerifier.test.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

test/ClaimVerifier.test.ts#L1093

[@typescript-eslint/no-unused-vars] 'namespace' is defined but never used.
const roleDef: IRoleDefinitionV2 = {
roleName: managerRole,
enrolmentPreconditions: [],
Expand Down
1 change: 1 addition & 0 deletions test/LoginStrategy.eip191token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
expect(token).toBeTruthy();

await loginStrategy?.validate(token, payload, (_, user) => {
console.info(`JH validated user log: ${user}`)
const jwt = new JWT(new Keys({ privateKey: userPrivKey }));
const decodedIdentity = jwt.decode(token) as {
[key: string]: string;
Expand Down Expand Up @@ -333,7 +334,7 @@
};

jest
.spyOn((credentialResolver as any)._ipfsCredentialResolver, 'eip191JwtsOf')

Check warning on line 337 in test/LoginStrategy.eip191token.test.ts

View workflow job for this annotation

GitHub Actions / deploy

Unexpected any. Specify a different type

Check warning on line 337 in test/LoginStrategy.eip191token.test.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

test/LoginStrategy.eip191token.test.ts#L337

[@typescript-eslint/no-explicit-any] Unexpected any. Specify a different type.
.mockReturnValueOnce([claim]);

const result = await credentialResolver.eip191JwtsOf(
Expand Down Expand Up @@ -540,7 +541,7 @@
// };

jest
.spyOn((credentialResolver as any)._ipfsStore, 'get')

Check warning on line 544 in test/LoginStrategy.eip191token.test.ts

View workflow job for this annotation

GitHub Actions / deploy

Unexpected any. Specify a different type

Check warning on line 544 in test/LoginStrategy.eip191token.test.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

test/LoginStrategy.eip191token.test.ts#L544

[@typescript-eslint/no-explicit-any] Unexpected any. Specify a different type.
.mockResolvedValueOnce('url');

// jest
Expand Down
Loading
Loading