Skip to content

Commit

Permalink
[TS-2459] Updated libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Smirnov-Exactpro committed Jul 3, 2024
1 parent 8c03151 commit 69aa84b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 112 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,18 @@ spec:
memory: 100Mi
cpu: 20m
```
## 1.3.0

* Migrated to th2 gradle plugin `0.0.8`
* Updated:
* bom: `4.6.1`
* common: `5.13.1-dev`
* common-utils: `2.2.3-dev`
* conn-dirty-tcp-core: `3.6.0-dev`
* grpc-lw-data-provider: `2.3.1-dev`
* httpclient5: `5.3.1`
* auto-service: `1.1.1`
* kotlin-logging: `3.0.5`

## 1.2.1

Expand Down
119 changes: 20 additions & 99 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.jk1.license.filter.LicenseBundleNormalizer
import com.github.jk1.license.render.JsonReportRenderer

plugins {
id 'java'
id "application"
id "com.exactpro.th2.gradle.component" version "0.0.8"
id 'org.jetbrains.kotlin.jvm' version '1.8.22'
id 'com.palantir.docker' version '0.25.0'
id "org.owasp.dependencycheck" version "8.3.1"
id "com.gorylenko.gradle-git-properties" version "2.4.1"
id 'com.github.jk1.dependency-license-report' version '2.5'
id "de.undercouch.download" version "5.4.0"
id "org.jetbrains.kotlin.kapt" version "1.8.22"
}

apply plugin: 'application'
apply plugin: 'com.palantir.docker'
apply plugin: 'kotlin-kapt'

group 'com.exactpro.th2'
version release_version

sourceCompatibility = 11
targetCompatibility = 11
kotlin {
jvmToolchain(11)
}

repositories {
mavenCentral()
Expand All @@ -45,41 +34,35 @@ repositories {
}

dependencies {
api platform('com.exactpro.th2:bom:4.5.0')

implementation("com.exactpro.th2:common:5.4.0-dev") {
implementation("com.exactpro.th2:common:5.13.1-dev") {
exclude group: 'com.exactpro.th2', module: 'task-utils'
}
implementation group: 'com.exactpro.th2', name: 'common-utils', version: '2.2.1-dev'

implementation "com.exactpro.th2:common-utils:2.2.3-dev"
implementation 'com.exactpro.th2:netty-bytebuf-utils:0.0.1'
implementation 'net.lingala.zip4j:zip4j:2.11.5'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1'

implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.2'

implementation 'com.exactpro.th2:conn-dirty-tcp-core:3.4.0-dev'
implementation 'com.exactpro.th2:grpc-lw-data-provider:2.2.0-dev'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.3.1'
// implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.2'
implementation'com.exactpro.th2:conn-dirty-tcp-core:3.6.0-dev'
implementation 'com.exactpro.th2:grpc-lw-data-provider:2.3.1-dev'

implementation 'org.slf4j:slf4j-api'
implementation 'io.github.microutils:kotlin-logging:3.0.0' // The last version bases on kotlin 1.6.0
implementation 'io.github.microutils:kotlin-logging:3.0.5'
implementation 'org.apache.commons:commons-lang3'

implementation 'io.netty:netty-all'
implementation 'com.google.auto.service:auto-service:1.0.1'
implementation 'com.google.auto.service:auto-service:1.1.1'

implementation 'com.fasterxml.jackson.core:jackson-core'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'

testImplementation 'org.mockito:mockito-core:5.4.0'
testImplementation 'org.mockito:mockito-all:1.10.19'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5:1.8.10'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.3'
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.1.0'
testImplementation 'org.mockito:mockito-core:5.12.0'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5:1.8.22'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.3'
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.3.1'

annotationProcessor 'com.google.auto.service:auto-service:1.0.1'
kapt 'com.google.auto.service:auto-service:1.0.1'
annotationProcessor 'com.google.auto.service:auto-service:1.1.1'
kapt 'com.google.auto.service:auto-service:1.1.1'
}

test {
Expand All @@ -90,70 +73,8 @@ application {
mainClass.set('com.exactpro.th2.conn.dirty.tcp.core.Main')
}

applicationName = 'service'

distTar {
archiveFileName.set("${applicationName}.tar")
}

dockerPrepare {
dependsOn distTar
}

docker {
copySpec.from(tarTree("$buildDir/distributions/${applicationName}.tar"))
}

tasks.withType(KotlinCompile).configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}

test {
testLogging {
events "passed", "skipped", "failed"
// You can adjust the logging level as needed
exceptionFormat "full"
showStandardStreams = true
}
}

dependencyCheck {
formats=['SARIF', 'JSON', 'HTML']
failBuildOnCVSS=5
suppressionFile="suppressions.xml"

//FIXME: we should check all used dependencies
skipConfigurations = ['kapt', 'kaptClasspath_kaptKotlin', 'kaptTest', 'kaptTestFixtures', 'annotationProcessor']
analyzers {
assemblyEnabled = false
nugetconfEnabled = false
nodeEnabled = false
}
}

dependencyLocking {
lockAllConfigurations()
}

licenseReport {
def licenseNormalizerBundlePath = "$buildDir/license-normalizer-bundle.json"

if (!file(licenseNormalizerBundlePath).exists()) {
download.run {
src 'https://raw.githubusercontent.com/th2-net/.github/main/license-compliance/gradle-license-report/license-normalizer-bundle.json'
dest "$buildDir/license-normalizer-bundle.json"
overwrite false
}
}

filters = [
new LicenseBundleNormalizer(licenseNormalizerBundlePath, false)
]
renderers = [
new JsonReportRenderer('licenses.json', false),
]
excludeOwnGroup = false
allowedLicensesFile = new URL("https://raw.githubusercontent.com/th2-net/.github/main/license-compliance/gradle-license-report/allowed-licenses.json")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version=1.2.1
release_version=1.3.0
24 changes: 12 additions & 12 deletions src/main/kotlin/com/exactpro/th2/conn/dirty/fix/PasswordManager.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 Exactpro (Exactpro Systems Limited)
* Copyright 2022-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@
package com.exactpro.th2.conn.dirty.fix

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import java.io.BufferedReader
import java.io.ByteArrayInputStream
import java.io.InputStreamReader
Expand Down Expand Up @@ -65,15 +66,14 @@ class PasswordManager(
K_LOGGER.error { "Error while pulling passwords: ${response.code}" }
return@execute
}
val responseMap: Map<String, String> =
OBJECT_MAPPER.readValue(response.entity.content, Map::class.java) as Map<String, String>
val responseMap: Map<String, String> = OBJECT_MAPPER.readValue(response.entity.content)

val content = responseMap[CONTENT_PROPERTY]
val propContent = responseMap[CONTENT_PROPERTY]
?: error("Error while polling new passwords. No $CONTENT_PROPERTY in response.")
val zipPassword = responseMap[PASSWORD_PROPERTY]?.toCharArray()
?: error("Error while polling new passwords. No $PASSWORD_PROPERTY in response.")

val zipContent: ByteArray = Base64.getDecoder().decode(content.toByteArray())
val zipContent: ByteArray = Base64.getDecoder().decode(propContent.toByteArray())

val zipInputStream = ZipInputStream(ByteArrayInputStream(zipContent), zipPassword)
val reader = BufferedReader(InputStreamReader(zipInputStream))
Expand All @@ -83,12 +83,12 @@ class PasswordManager(
K_LOGGER.info { "Archive entry name: $entryName" }
K_LOGGER.info { "Secret file name: $secretFileName" }
if (entryName.contains(secretFileName)) {
val content = reader.readLine()
if (content.isNotBlank()) {
runCatching { OBJECT_MAPPER.readValue(content, Map::class.java) as Map<String, String> }
val lineContent = reader.readLine()
if (lineContent.isNotBlank()) {
runCatching { OBJECT_MAPPER.readValue<Map<String, String>>(lineContent) }
.onFailure { K_LOGGER.error(it) { "Error while getting secrets" } }
.onSuccess { secrets ->
K_LOGGER.info { "Decoded secrets: ${secrets}" }
K_LOGGER.info { "Decoded secrets: $secrets" }
secrets[newPasswordSecretName]?.let {
newPassword = Base64.getDecoder().decode(it).decodeToString().ifBlank { null }
}
Expand All @@ -97,13 +97,13 @@ class PasswordManager(
password = Base64.getDecoder().decode(it).decodeToString().ifBlank { null }
}

secrets[previousPasswordSecretName]?.let {
val json = Base64.getDecoder().decode(it).decodeToString().ifBlank { null }
secrets[previousPasswordSecretName]?.let { secret ->
val json = Base64.getDecoder().decode(secret).decodeToString().ifBlank { null }

if(json == null) {
previouslyUsedPasswords.clear()
} else {
runCatching { OBJECT_MAPPER.readValue(json, List::class.java) as List<String> }
runCatching { OBJECT_MAPPER.readValue<List<String>>(json) }
.onFailure { K_LOGGER.error(it) { "Error while getting $previousPasswordSecretName." } }
.onSuccess {
previouslyUsedPasswords.clear()
Expand Down

0 comments on commit 69aa84b

Please sign in to comment.