Skip to content

Commit

Permalink
Merge pull request #436 from TimoGlastra/fix/afj-revocation
Browse files Browse the repository at this point in the history
fix(afj): revocation tests
  • Loading branch information
swcurran authored Feb 17, 2022
2 parents 2bd05d7 + 79eb9be commit 4203dd9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-harness-acapy-afj.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
BUILD_AGENTS: "-a acapy-main -a javascript"
TEST_AGENTS: "-d acapy-main -b javascript"
TEST_SCOPE: "-t @AcceptanceTest -t @AIP10,@revocation -t ~@wip -t ~@DIDExchangeConnection"
TEST_SCOPE: "-t @AcceptanceTest -t @AIP10,@RFC0441 -t ~@wip -t ~@DIDExchangeConnection"
REPORT_PROJECT: acapy-b-javascript
continue-on-error: true
- name: run-send-gen-test-results-secure
Expand Down
9 changes: 9 additions & 0 deletions aries-backchannels/javascript/server/src/TestAgent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { $log } from '@tsed/common'
import { Agent, HttpOutboundTransport, InitConfig, WsOutboundTransport } from '@aries-framework/core'
import { agentDependencies, HttpInboundTransport } from '@aries-framework/node'
import indy from 'indy-sdk'

import { TsedLogger } from './TsedLogger'

Expand All @@ -23,6 +24,14 @@ export async function createAgent({
// TODO: Schema is prob already registered
$log.level = 'debug'

// @ts-ignore
indy.setLogger(function (level: string, target: string, message: string, modulePath: string, file: string, line: string) {
console.log('libindy said:', level, target, message, modulePath, file, line)
})

// @ts-ignore
indy.setRuntimeConfig({ collect_backtrace: true })

const agentConfig: InitConfig = {
label: agentName,
walletConfig: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import {
ProofRequest,
RequestedCredentials,
ProofRecord,
IndyCredentialInfo,
AgentConfig,
Logger,
ProofEventTypes,
ProofStateChangedEvent,
ProofState,
RequestedAttribute,
RequestedPredicate,
} from '@aries-framework/core'
import { CredentialUtils } from '../utils/CredentialUtils'
import { ProofUtils } from '../utils/ProofUtils'
import { filter, firstValueFrom, ReplaySubject, timeout } from 'rxjs'
import util from 'util'

@Controller('/agent/command/proof')
export class PresentProofController {
Expand Down Expand Up @@ -135,31 +136,33 @@ export class PresentProofController {
RequestedCredentials
)

this.logger.info('Created requested credentials ', {
requestedCredentials: JSON.stringify(requestedCredentials.toJSON(), null, 2),
const retrievedCredentials = await this.agent.proofs.getRequestedCredentialsForProofRequest(proofRecord.id, {
filterByPresentationPreview: true,
// Some tests include presenting a revoked credential, expecting the verification to fail
// So not excluding those from the retrieved credentials.
filterByNonRevocationRequirements: false,
})

const credentialUtils = new CredentialUtils(this.agent)
Object.values(requestedCredentials.requestedAttributes).forEach(async (requestedAttribute) => {
const credentialInfo = JsonTransformer.fromJSON(
await credentialUtils.getIndyCredentialById(requestedAttribute.credentialId),
IndyCredentialInfo
)
requestedAttribute.credentialInfo = credentialInfo
this.logger.info('Created proof request', {
requestedCredentials: util.inspect(requestedCredentials, { showHidden: false, depth: null }),
retrievedCredentials: util.inspect(retrievedCredentials, { showHidden: false, depth: null }),
})
Object.values(requestedCredentials.requestedPredicates).forEach(async (requestedPredicate) => {
const credentialInfo = JsonTransformer.fromJSON(
await credentialUtils.getIndyCredentialById(requestedPredicate.credentialId),
IndyCredentialInfo
)
requestedPredicate.credentialInfo = credentialInfo

Object.keys(requestedCredentials.requestedAttributes).forEach((key) => {
requestedCredentials.requestedAttributes[key] = retrievedCredentials.requestedAttributes[key].find(
(a) => a.credentialId === requestedCredentials.requestedAttributes[key].credentialId
) as RequestedAttribute
})

this.logger.info('Created proof request ', {
requestedCredentials: requestedCredentials.toJSON(),
Object.keys(requestedCredentials.requestedPredicates).forEach((key) => {
requestedCredentials.requestedPredicates[key] = retrievedCredentials.requestedPredicates[key].find(
(p) => p.credentialId === requestedCredentials.requestedPredicates[key].credentialId
) as RequestedPredicate
})

proofRecord = await this.agent.proofs.acceptRequest(proofRecord.id, requestedCredentials, { comment: data.comment })
proofRecord = await this.agent.proofs.acceptRequest(proofRecord.id, requestedCredentials, {
comment: data.comment,
})

return this.mapProofRecord(proofRecord)
}
Expand Down
6 changes: 3 additions & 3 deletions aries-test-harness/features/0183-revocation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Feature: RFC 0183 Aries agent credential revocation and revocation notification
| issuer | credential_data | request_for_proof | presentation |
| Acme | Data_DL_MaxValues | proof_request_DL_revoc_address | presentation_DL_revoc_address |

@T002-HIPE0011 @critical @AcceptanceTest @Schema_DriversLicense_Revoc @Indy
@T002-HIPE0011 @critical @AcceptanceTest @Schema_DriversLicense_Revoc @Indy @RFC0441
Scenario Outline: Credential revoked and replaced with a new updated credential, holder proves claims with the updated credential with timesstamp
Given "2" agents
| name | role |
Expand Down Expand Up @@ -329,7 +329,7 @@ Feature: RFC 0183 Aries agent credential revocation and revocation notification
| issuer | credential_data | request_for_proof | presentation |
| Acme | Data_DL_MaxValues | proof_request_DL_revoc_address | presentation_DL_revoc_address |

@T013-HIPE0011 @normal @AcceptanceTest @Schema_DriversLicense @Indy
@T013-HIPE0011 @normal @AcceptanceTest @Schema_DriversLicense @Indy @RFC0441
Scenario Outline: Non-revocable Credential, not revoked, and holder proves claims with the credential with timesstamp
Given "2" agents
| name | role |
Expand All @@ -346,7 +346,7 @@ Feature: RFC 0183 Aries agent credential revocation and revocation notification
| issuer | credential_data | timeframe | request_for_proof | presentation |
| Acme | Data_DL_MinValues | now:now | proof_request_DL_address | presentation_DL_address_w_ts |

@T014-HIPE0011 @normal @AcceptanceTest @Schema_DriversLicense_Revoc @Indy
@T014-HIPE0011 @normal @AcceptanceTest @Schema_DriversLicense_Revoc @Indy @RFC0441
Scenario Outline: Revocable Credential, not revoked, and holder proves claims with the credential with timesstamp
Given "2" agents
| name | role |
Expand Down

0 comments on commit 4203dd9

Please sign in to comment.