Skip to content

Commit

Permalink
style: megalinter fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Shynbuiev <yurii.shynbuiev@iohk.io>
  • Loading branch information
yshyn-iohk committed Jan 15, 2025
1 parent 5c89fa3 commit f9d1430
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 58 deletions.
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,
claims = claims,
issuingDID = did,
issuingKid = assertionKey,
connectionId = connectionId,
validityPeriod = validityPeriod ?: 3600.0,
credentialFormat = credentialType.format,
automaticIssuance = false,
)
}
): CreateIssueCredentialRecordRequest = CreateIssueCredentialRecordRequest(
schemaId = schemaUrl,
claims = claims,
issuingDID = did,
issuingKid = assertionKey,
connectionId = connectionId,
validityPeriod = validityPeriod ?: 3600.0,
credentialFormat = credentialType.format,
automaticIssuance = false,
)
},

V1 {
Expand All @@ -36,25 +34,23 @@ enum class CreateCredentialOfferAPIVersion {
claims: Map<String, Any>,
connectionId: UUID,
validityPeriod: Double?,
): CreateIssueCredentialRecordRequest {
return CreateIssueCredentialRecordRequest(
issuingKid = assertionKey,
connectionId = connectionId,
credentialFormat = credentialType.format,
automaticIssuance = false,
claims = null,
issuingDID = "",
jwtVcPropertiesV1 = JwtVCPropertiesV1(
credentialSchema = CredentialSchemaRef(
id = schemaUrl!!,
type = "JsonSchemaValidator2018",
),
claims = claims,
issuingDID = did,
validityPeriod = validityPeriod ?: 3600.0,
): CreateIssueCredentialRecordRequest = CreateIssueCredentialRecordRequest(
issuingKid = assertionKey,
connectionId = connectionId,
credentialFormat = credentialType.format,
automaticIssuance = false,
claims = null,
issuingDID = "",
jwtVcPropertiesV1 = JwtVCPropertiesV1(
credentialSchema = CredentialSchemaRef(
id = schemaUrl!!,
type = "JsonSchemaValidator2018",
),
)
}
claims = claims,
issuingDID = did,
validityPeriod = validityPeriod ?: 3600.0,
),
)
},
;

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()
}

0 comments on commit f9d1430

Please sign in to comment.