Skip to content

Commit

Permalink
Fix Crypted.toBase64
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-lamed committed Aug 22, 2022
1 parent d145970 commit 67f4bde
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crypto/src/main/scala/uk/gov/hmrc/crypto/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ case class PlainBytes(value: Array[Byte]) extends PlainContent

case class Crypted(value: String) {
def toBase64 =
Base64.getDecoder.decode(value.getBytes("UTF-8"))
Base64.getEncoder.encode(value.getBytes("UTF-8"))
}

object Crypted extends (String => Crypted) {
Expand Down
29 changes: 29 additions & 0 deletions crypto/src/test/scala/uk/gov/hmrc/crypto/ModelSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2022 HM Revenue & Customs
*
* 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.
*/

package uk.gov.hmrc.crypto

import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpecLike

class ModelSpec extends AnyWordSpecLike with Matchers {
"Crypted" should {
"encode and decode Base64" in {
val encrypted = Crypted("")
Crypted.fromBase64(new String(encrypted.toBase64)).value shouldBe encrypted.value
}
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.8
sbt.version=1.6.2
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2")
resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns)

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.7.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.8.0")

0 comments on commit 67f4bde

Please sign in to comment.