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

style: apply linters automatic fixes #1477

Open
wants to merge 1 commit into
base: feat/vcdm1_1-tests
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ enum class CreateCredentialOfferAPIVersion {
claims: Map<String, Any>,
connectionId: UUID,
validityPeriod: Double?,
): CreateIssueCredentialRecordRequest {
return CreateIssueCredentialRecordRequest(
schemaId = schemaUrl?.let { listOf(it) },
claims = claims,
issuingDID = did,
issuingKid = assertionKey,
connectionId = connectionId,
validityPeriod = validityPeriod ?: 3600.0,
credentialFormat = credentialType.format,
automaticIssuance = false,
)
}
): CreateIssueCredentialRecordRequest = CreateIssueCredentialRecordRequest(
schemaId = schemaUrl?.let { listOf(it) },
claims = claims,
issuingDID = did,
issuingKid = assertionKey,
connectionId = connectionId,
validityPeriod = validityPeriod ?: 3600.0,
credentialFormat = credentialType.format,
automaticIssuance = false,
)
},

// TODO: it's a copy/paste from the V0, I have to regenerate the Kotlin HTTP client
Expand All @@ -37,18 +35,16 @@ enum class CreateCredentialOfferAPIVersion {
claims: Map<String, Any>,
connectionId: UUID,
validityPeriod: Double?,
): CreateIssueCredentialRecordRequest {
return CreateIssueCredentialRecordRequest(
schemaId = schemaUrl?.let { listOf(it) },
claims = claims,
issuingDID = did,
issuingKid = assertionKey,
connectionId = connectionId,
validityPeriod = validityPeriod ?: 3600.0,
credentialFormat = credentialType.format,
automaticIssuance = false,
)
}
): CreateIssueCredentialRecordRequest = CreateIssueCredentialRecordRequest(
schemaId = schemaUrl?.let { listOf(it) },
claims = claims,
issuingDID = did,
issuingKid = assertionKey,
connectionId = connectionId,
validityPeriod = validityPeriod ?: 3600.0,
credentialFormat = credentialType.format,
automaticIssuance = false,
)
},
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import net.serenitybdd.screenplay.Actor

enum class SchemaErrorTemplate {
TYPE_AND_PROPERTIES_WITHOUT_SCHEMA_TYPE {
override fun innerSchema(): String {
return """
override fun innerSchema(): String = """
{
"type": "object",
"properties": {
Expand All @@ -21,12 +20,10 @@ enum class SchemaErrorTemplate {
},
"required": ["name"]
}
""".trimIndent()
}
""".trimIndent()
},
CUSTOM_WORDS_NOT_DEFINED {
override fun innerSchema(): String {
return """
override fun innerSchema(): String = """
{
"${"$"}schema": "http://json-schema.org/draft-2020-12/schema#",
"type": "object",
Expand All @@ -40,12 +37,10 @@ enum class SchemaErrorTemplate {
},
"customKeyword": "value"
}
""".trimIndent()
}
""".trimIndent()
},
MISSING_REQUIRED_FOR_MANDATORY_PROPERTY {
override fun innerSchema(): String {
return """
override fun innerSchema(): String = """
{
"${"$"}schema": "http://json-schema.org/draft-2020-12/schema#",
"type": "object",
Expand All @@ -59,7 +54,6 @@ enum class SchemaErrorTemplate {
}
}
"""
}
}, ;

abstract fun innerSchema(): String
Expand Down
26 changes: 9 additions & 17 deletions tests/integration-tests/src/test/kotlin/models/JwtCredential.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@ class JwtCredential {
val provider: Provider = BouncyCastleProvider()
val keys: MutableMap<String, Key<out Serializable>> = mutableMapOf()

fun parseBase64(base64: String): JwtCredential {
return JwtCredential().parseBase64(base64)
}
fun parseBase64(base64: String): JwtCredential = JwtCredential().parseBase64(base64)

fun parseJwt(jwt: String): JwtCredential {
return JwtCredential().parseJwt(jwt)
}
fun parseJwt(jwt: String): JwtCredential = JwtCredential().parseJwt(jwt)

fun verify(jwt: String, verification: List<VerificationMethod>): Boolean {
val signedJWT = SignedJWT.parse(jwt)
Expand Down Expand Up @@ -118,15 +114,13 @@ class JwtCredential {
return signer
}

private fun parseKey(key: String): JWK {
return try {
ECKey.parse(key)
private fun parseKey(key: String): JWK = try {
ECKey.parse(key)
} catch (e: Exception) {
try {
OctetKeyPair.parse(key)
} catch (e: Exception) {
try {
OctetKeyPair.parse(key)
} catch (e: Exception) {
throw IllegalArgumentException("Invalid key [$key]", e)
}
throw IllegalArgumentException("Invalid key [$key]", e)
}
}

Expand Down Expand Up @@ -209,7 +203,5 @@ class JwtCredential {
return this
}

fun serialize(): String {
return SignedJWT(header!!.toBase64URL(), payload!!.toBase64URL(), signature!!).serialize()
}
fun serialize(): String = SignedJWT(header!!.toBase64URL(), payload!!.toBase64URL(), signature!!).serialize()
}