-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from lensesio/feat/vault-secret-provider-rotation
Vault - Secret Provider Rotation
- Loading branch information
Showing
33 changed files
with
1,574 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- --> | ||
<!-- Copyright 2021 Celonis. --> | ||
<!-- --> | ||
<!-- Licensed under the Apache License, Version 2.0 (the "License"); --> | ||
<!-- you may not use this file except in compliance with the License. --> | ||
<!-- You may obtain a copy of the License at --> | ||
<!-- --> | ||
<!-- http://www.apache.org/licenses/LICENSE-2.0 --> | ||
<!-- --> | ||
<!-- Unless required by applicable law or agreed to in writing, software --> | ||
<!-- distributed under the License is distributed on an "AS IS" BASIS, --> | ||
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> | ||
<!-- See the License for the specific language governing permissions and --> | ||
<!-- limitations under the License. --> | ||
<!-- --> | ||
<configuration> | ||
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | ||
<Target>System.out</Target> | ||
<encoder> | ||
<pattern>%d{ISO8601} %-5p %X{dbz.connectorType}|%X{dbz.connectorName}|%X{dbz.connectorContext} %m [%c]%n</pattern> | ||
</encoder> | ||
</appender> | ||
<logger name="io.lenses" level="INFO"/> | ||
<logger name="com.datamountaineer" level="INFO"/> | ||
<logger name="org.apache.kafka.connect.json.JsonConverterConfig" level="WARN"/> | ||
<root level="INFO"> | ||
<appender-ref ref="stdout"/> | ||
</root> | ||
</configuration> |
Large diffs are not rendered by default.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
...vider/src/it/scala/io/lenses/connect/secrets/integration/SecretProviderRestResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.lenses.connect.secrets.integration | ||
|
||
import com.bettercloud.vault.rest.RestResponse | ||
import org.json4s.DefaultFormats | ||
import org.json4s._ | ||
import org.json4s.native.JsonMethods._ | ||
|
||
case class DataResponse( | ||
data: Map[String, Any], | ||
metadata: Map[String, Any], | ||
) | ||
case class SecretProviderRestResponse( | ||
requestId: String, | ||
leaseId: String, | ||
renewable: Boolean, | ||
leaseDuration: BigInt, | ||
data: DataResponse, | ||
wrapInfo: Any, // todo what is this? | ||
warnings: Any, // todo | ||
auth: Any, // todo | ||
) | ||
|
||
case object SecretProviderRestResponse { | ||
|
||
def fromRestResponse(rr: RestResponse) = | ||
fromJson(new String(rr.getBody)) | ||
|
||
def fromJson(json: String) = { | ||
implicit val formats: DefaultFormats.type = DefaultFormats | ||
|
||
parse(json).camelizeKeys.extract[SecretProviderRestResponse] | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...r/src/it/scala/io/lenses/connect/secrets/integration/SecretProviderRestResponseTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.lenses.connect.secrets.integration | ||
|
||
import org.scalatest.funsuite.AnyFunSuite | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class SecretProviderRestResponseTest extends AnyFunSuite with Matchers { | ||
|
||
private val sampleJson = | ||
"""{"request_id":"41398853-3a2f-ba6b-7c37-23b201941071","lease_id":"","renewable":false,"lease_duration":20,"data": {"data":{"myVaultSecretKey":"myVaultSecretValue"}, "metadata":{"created_time":"2023-02-28T10:49:56.854615Z","custom_metadata":null,"deletion_time":"","destroyed":false,"version":1}},"wrap_info":null,"warnings":null,"auth":null}""" | ||
|
||
test("Should unmarshal sample json") { | ||
val sprr = SecretProviderRestResponse.fromJson(sampleJson) | ||
|
||
sprr.requestId should be("41398853-3a2f-ba6b-7c37-23b201941071") | ||
sprr.leaseDuration should be(20) | ||
sprr.data.data should be(Map[String, Any]("myVaultSecretKey" -> "myVaultSecretValue")) | ||
sprr.data.metadata.toSet should be( | ||
Set( | ||
"createdTime" -> "2023-02-28T10:49:56.854615Z", | ||
"customMetadata" -> null, | ||
"deletionTime" -> "", | ||
"destroyed" -> false, | ||
"version" -> Integer.valueOf(1), | ||
), | ||
) | ||
} | ||
|
||
} |
Oops, something went wrong.