Skip to content

Commit

Permalink
chore: SDK-38 update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Oct 23, 2024
1 parent 30235e0 commit 0af330d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/issuer-rest/lib/__tests__/ClientIssuerIT.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('VcIssuer', () => {

const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withIssuer(ISSUER_URL)
.withCredentialEndpoint('http://localhost:3456/test/credential-endpoin')
.withCredentialEndpoint('http://localhost:3456/test/credential-endpoint')
.withTokenEndpoint('http://localhost:3456/test/token')
.withAuthorizationEndpoint('https://token-endpoint.example.com/authorize')
.withTokenEndpointAuthMethodsSupported(['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post'])
Expand Down Expand Up @@ -270,7 +270,7 @@ describe('VcIssuer', () => {
await expect(client.retrieveServerMetadata()).resolves.toEqual({
authorizationServerMetadata: {
'authorization_endpoint': 'https://token-endpoint.example.com/authorize',
'credential_endpoint': 'http://localhost:3456/test/credential-endpoin',
'credential_endpoint': 'http://localhost:3456/test/credential-endpoint',
'issuer': 'http://localhost:3456/test',
'response_types_supported': [
'code',
Expand Down
43 changes: 30 additions & 13 deletions packages/issuer-rest/lib/__tests__/IssuerTokenServer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
URIState,
} from '@sphereon/oid4vci-common'
import { VcIssuer } from '@sphereon/oid4vci-issuer'
import {
AuthorizationServerMetadataBuilder
} from '@sphereon/oid4vci-issuer/dist/builder/AuthorizationServerMetadataBuilder'
import { MemoryStates } from '@sphereon/oid4vci-issuer/dist/state-manager'
import { ExpressBuilder, ExpressSupport } from '@sphereon/ssi-express-support'
import { DIDDocument } from 'did-resolver'
Expand All @@ -21,6 +24,19 @@ import requests from 'supertest'

import { OID4VCIServer } from '../OID4VCIServer'



const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withIssuer('test-issuer')
.withCredentialEndpoint('http://localhost:3456/test/credential-endpoint')
.withTokenEndpoint('http://localhost:3456/test/token')
.withAuthorizationEndpoint('https://token-endpoint.example.com/authorize')
.withTokenEndpointAuthMethodsSupported(['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post'])
.withResponseTypesSupported(['code', 'token', 'id_token'])
.withScopesSupported(['openid', 'abcdef'])
.build();


describe('OID4VCIServer', () => {
let app: Express
let expressSupport: ExpressSupport
Expand Down Expand Up @@ -107,11 +123,11 @@ describe('OID4VCIServer', () => {
display: [
{
name: 'given name',
locale: 'en-US',
},
],
},
},
locale: 'en-US'
}
]
}
}
},
format: 'jwt_vc_json',
credential_signing_alg_values_supported: ['ES256K'],
Expand All @@ -122,21 +138,22 @@ describe('OID4VCIServer', () => {
locale: 'en-US',
logo: {
url: 'https://exampleuniversity.com/public/logo.png',
alt_text: 'a square logo of a university',
alt_text: 'a square logo of a university'
},
background_color: '#12107c',
text_color: '#FFFFFF',
},
],
},
},
text_color: '#FFFFFF'
}
]
}
}
} as CredentialIssuerMetadataOptsV1_0_13,
authorizationServerMetadata,
{
cNonceExpiresIn: 300,
credentialOfferSessions,
cNonces: new MemoryStates<CNonceState>(),
uris: new MemoryStates<URIState>(),
},
uris: new MemoryStates<URIState>()
}
)

expressSupport = ExpressBuilder.fromServerOpts({
Expand Down
14 changes: 14 additions & 0 deletions packages/issuer/lib/__tests__/VcIssuer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { DIDDocument } from 'did-resolver'

import { VcIssuer } from '../VcIssuer'
import { CredentialSupportedBuilderV1_13, VcIssuerBuilder } from '../builder'
import { AuthorizationServerMetadataBuilder } from '../builder/AuthorizationServerMetadataBuilder'
import { MemoryStates } from '../state-manager'

const IDENTIPROOF_ISSUER_URL = 'https://issuer.research.identiproof.io'
Expand Down Expand Up @@ -48,6 +49,17 @@ const verifiableCredential_withoutDid = {
},
}

const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withIssuer(IDENTIPROOF_ISSUER_URL)
.withCredentialEndpoint('http://localhost:3456/test/credential-endpoint')
.withTokenEndpoint('http://localhost:3456/test/token')
.withAuthorizationEndpoint('https://token-endpoint.example.com/authorize')
.withTokenEndpointAuthMethodsSupported(['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post'])
.withResponseTypesSupported(['code', 'token', 'id_token'])
.withScopesSupported(['openid', 'abcdef'])
.build();


describe('VcIssuer', () => {
let vcIssuer: VcIssuer<DIDDocument>
const issuerState = 'previously-created-state'
Expand Down Expand Up @@ -121,6 +133,7 @@ describe('VcIssuer', () => {
.withAuthorizationServers('https://authorization-server')
.withCredentialEndpoint('https://credential-endpoint')
.withCredentialIssuer(IDENTIPROOF_ISSUER_URL)
.withAuthorizationMetadata(authorizationServerMetadata)
.withIssuerDisplay({
name: 'example issuer',
locale: 'en-US',
Expand Down Expand Up @@ -520,6 +533,7 @@ describe('VcIssuer without did', () => {
.withAuthorizationServers('https://authorization-server')
.withCredentialEndpoint('https://credential-endpoint')
.withCredentialIssuer(IDENTIPROOF_ISSUER_URL)
.withAuthorizationMetadata(authorizationServerMetadata)
.withIssuerDisplay({
name: 'example issuer',
locale: 'en-US',
Expand Down
16 changes: 16 additions & 0 deletions packages/issuer/lib/__tests__/VcIssuerBuilder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { uuidv4 } from '@sphereon/oid4vc-common'
import { CredentialConfigurationSupportedV1_0_13, IssuerCredentialSubjectDisplay, IssueStatus, TokenErrorResponse } from '@sphereon/oid4vci-common'

import { AuthorizationServerMetadataBuilder } from '../builder/AuthorizationServerMetadataBuilder'
import { CredentialSupportedBuilderV1_13, VcIssuerBuilder } from '../index'


const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withIssuer('https://credential-issuer')
.withCredentialEndpoint('https://credential-endpoint')
.withTokenEndpoint('https://token-endpoint')
.withAuthorizationEndpoint('https://token-endpoint/authorize')
.withTokenEndpointAuthMethodsSupported(['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post'])
.withResponseTypesSupported(['code', 'token', 'id_token'])
.withScopesSupported(['openid', 'abcdef'])
.build();


describe('VcIssuer builder should', () => {
it('generate a VcIssuer', () => {
const credentialsSupported: Record<string, CredentialConfigurationSupportedV1_0_13> = new CredentialSupportedBuilderV1_13()
Expand Down Expand Up @@ -32,6 +45,7 @@ describe('VcIssuer builder should', () => {
.withAuthorizationServers('https://authorization-server')
.withCredentialEndpoint('https://credential-endpoint')
.withCredentialIssuer('https://credential-issuer')
.withAuthorizationMetadata(authorizationServerMetadata)
.withIssuerDisplay({
name: 'example issuer',
locale: 'en-US',
Expand Down Expand Up @@ -120,6 +134,7 @@ describe('VcIssuer builder should', () => {
.withAuthorizationServers('https://authorization-server')
.withCredentialEndpoint('https://credential-endpoint')
.withCredentialIssuer('https://credential-issuer')
.withAuthorizationMetadata(authorizationServerMetadata)
.withIssuerDisplay({
name: 'example issuer',
locale: 'en-US',
Expand Down Expand Up @@ -179,6 +194,7 @@ describe('VcIssuer builder should', () => {
.withAuthorizationServers('https://authorization-server')
.withCredentialEndpoint('https://credential-endpoint')
.withCredentialIssuer('https://credential-issuer')
.withAuthorizationMetadata(authorizationServerMetadata)
.withIssuerDisplay({
name: 'example issuer',
locale: 'en-US',
Expand Down

0 comments on commit 0af330d

Please sign in to comment.