Skip to content

Commit

Permalink
[fix] wallet updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dtsiflit committed Jan 18, 2024
1 parent bd9802e commit 6bb43d1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
12 changes: 6 additions & 6 deletions Tests/Constants/TestsConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import Foundation
@testable import OpenID4VCI

//let CredentialIssuer_URL = "http://localhost:8080"
//let CredentialIssuer_URL = "https://preprod.issuer.eudiw.dev/oidc"
let CredentialIssuer_URL = "https://eudi.netcompany-intrasoft.com/pid-issuer"
let CredentialIssuer_URL = "https://preprod.issuer.eudiw.dev/oidc"
//let CredentialIssuer_URL = "https://eudi.netcompany-intrasoft.com/pid-issuer"

let PID_SdJwtVC_SCOPE = "eu.europa.ec.eudiw.pid_vc_sd_jwt"
let PID_MsoMdoc_SCOPE = "eu.europa.ec.eudiw.pid_mso_mdoc"
//let PID_SdJwtVC_SCOPE = "eu.europa.ec.eudiw.pid_jwt_vc_json"
//let PID_MsoMdoc_SCOPE = "eu.europa.ec.eudiw.pid_mdoc"
//let PID_SdJwtVC_SCOPE = "eu.europa.ec.eudiw.pid_vc_sd_jwt"
//let PID_MsoMdoc_SCOPE = "eu.europa.ec.eudiw.pid_mso_mdoc"
let PID_SdJwtVC_SCOPE = "eu.europa.ec.eudiw.pid_jwt_vc_json"
let PID_MsoMdoc_SCOPE = "eu.europa.ec.eudiw.pid_mdoc"

let All_Supported_CredentialOffer = """
{
Expand Down
48 changes: 31 additions & 17 deletions Tests/Helpers/Wallet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ struct Wallet {
let bindingKey: BindingKey
}

enum WalletMode {
case doesNorRequireIntervention
case requiresIntervention
}

extension Wallet {
func issueByCredentialIdentifier(_ identifier: String) async throws -> String {
let credentialIdentifier = try CredentialIdentifier(value: identifier)
Expand Down Expand Up @@ -239,25 +244,34 @@ extension Wallet {
case let .par(parRequested) = request {
print("--> [AUTHORIZATION] Placed PAR. Get authorization code URL is: \(parRequested.getAuthorizationCodeURL)")

// let authorizationCode = try await loginUserAndGetAuthCode(
// getAuthorizationCodeUrl: parRequested.getAuthorizationCodeURL.url,
// actingUser: actingUser
// ) ?? { throw ValidationError.error(reason: "Could not retrieve authorization code") }()
var authorizationCode = ""
print("--> [AUTHORIZATION] Authorization code retrieved: \(authorizationCode)")

var issuanceAuthorization: IssuanceAuthorization = .authorizationCode(authorizationCode: authorizationCode)

let unAuthorized = await issuer.handleAuthorizationCode(
parRequested: request,
code: &authorizationCode
)
var unAuthorized: Result<UnauthorizedRequest, Error>
var authorizationCode: String

// let unAuthorized = await issuer.handleAuthorizationCode(
// parRequested: request,
// authorizationCode: issuanceAuthorization
// )
// Depending on the mode selected, changes might be
// required on the tests constants file (endpoints, scopes)
let walletMode: WalletMode = .requiresIntervention

switch walletMode {
case .doesNorRequireIntervention:
authorizationCode = try await loginUserAndGetAuthCode(
getAuthorizationCodeUrl: parRequested.getAuthorizationCodeURL.url,
actingUser: actingUser
) ?? { throw ValidationError.error(reason: "Could not retrieve authorization code") }()
let issuanceAuthorization: IssuanceAuthorization = .authorizationCode(authorizationCode: authorizationCode)
unAuthorized = await issuer.handleAuthorizationCode(
parRequested: request,
authorizationCode: issuanceAuthorization
)

case .requiresIntervention:
authorizationCode = ""
unAuthorized = await issuer.handleAuthorizationCode(
parRequested: request,
code: &authorizationCode
)
}

print("--> [AUTHORIZATION] Authorization code retrieved: \(authorizationCode)")

switch unAuthorized {
case .success(let request):
Expand Down

0 comments on commit 6bb43d1

Please sign in to comment.