<commit_before>package utils.helpers

import org.scalatest.{Matchers, WordSpec}
import play.api.test.{FakeApplication, WithApplication}

final class AesEncryptionSpec extends WordSpec with Matchers {
  "encryptCookie" should {
    "return an encrypted string" in new WithApplication(app = fakeAppWithCryptoConfig) {
      val aesEncryption = new AesEncryption
      aesEncryption.encrypt(ClearText) should not equal ClearText
    }

    "return a different encrypted string given same clear text input" in new WithApplication(app = fakeAppWithCryptoConfig) {
      val aesEncryption = new AesEncryption
      val cipherText1 = aesEncryption.encrypt(ClearText)
      val cipherText2 = aesEncryption.encrypt(ClearText)

      withClue("Initialization vectors must be used to ensure output is always random") {
        cipherText1 should not equal cipherText2
      }
    }

    "throw an exception when the application secret key is the wrong size" in new WithApplication(app = fakeAppWithWrongLengthAppSecretConfig) {
      intercept[Exception] {
        val aesEncryption = new AesEncryption
        aesEncryption.encrypt(ClearText)
      }
    }
/*
    "throw an exception when the application secret key is missing from config" in new WithApplication(app = fakeAppWithNoAppSecretConfig) {
      intercept[Exception] {
        val aesEncryption = new AesEncryption
        aesEncryption.encrypt(ClearText)
      }
    }
*/
  }

  "decryptCookie" should {
    "return a decrypted string" in new WithApplication(app = fakeAppWithCryptoConfig) {
      val aesEncryption = new AesEncryption
      val encrypted = aesEncryption.encrypt(ClearText)
      aesEncryption.decrypt(encrypted) should equal(ClearText)
    }
  }

  private final val ClearText = "qwerty"
  private val fakeAppWithCryptoConfig = FakeApplication(
    additionalConfiguration = Map("application.secret256Bit" -> "MnPSvGpiEF5OJRG3xLAnsfmdMTLr6wpmJmZLv2RB9Vo="))
  private val fakeAppWithWrongLengthAppSecretConfig = FakeApplication(
    additionalConfiguration = Map("application.secret256Bit" -> "rubbish"))
//  private val fakeAppWithNoAppSecretConfig = FakeApplication(
//    additionalConfiguration = Map())

}
<commit_msg>Removed commented out tests<commit_after>package utils.helpers

import org.scalatest.{Matchers, WordSpec}
import play.api.test.{FakeApplication, WithApplication}

final class AesEncryptionSpec extends WordSpec with Matchers {
  "encryptCookie" should {
    "return an encrypted string" in new WithApplication(app = fakeAppWithCryptoConfig) {
      val aesEncryption = new AesEncryption
      aesEncryption.encrypt(ClearText) should not equal ClearText
    }

    "return a different encrypted string given same clear text input" in new WithApplication(app = fakeAppWithCryptoConfig) {
      val aesEncryption = new AesEncryption
      val cipherText1 = aesEncryption.encrypt(ClearText)
      val cipherText2 = aesEncryption.encrypt(ClearText)

      withClue("Initialization vectors must be used to ensure output is always random") {
        cipherText1 should not equal cipherText2
      }
    }

    "throw an exception when the application secret key is the wrong size" in new WithApplication(app = fakeAppWithWrongLengthAppSecretConfig) {
      intercept[Exception] {
        val aesEncryption = new AesEncryption
        aesEncryption.encrypt(ClearText)
      }
    }
  }

  "decryptCookie" should {
    "return a decrypted string" in new WithApplication(app = fakeAppWithCryptoConfig) {
      val aesEncryption = new AesEncryption
      val encrypted = aesEncryption.encrypt(ClearText)
      aesEncryption.decrypt(encrypted) should equal(ClearText)
    }
  }

  private final val ClearText = "qwerty"
  private val fakeAppWithCryptoConfig = FakeApplication(
    additionalConfiguration = Map("application.secret256Bit" -> "MnPSvGpiEF5OJRG3xLAnsfmdMTLr6wpmJmZLv2RB9Vo="))
  private val fakeAppWithWrongLengthAppSecretConfig = FakeApplication(
    additionalConfiguration = Map("application.secret256Bit" -> "rubbish"))

}

{'fraction_non_alphanumeric': 0.06691542288557215, 'fraction_numerical': 0.007462686567164179, 'mean_word_length': 4.148527528809219, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1203803', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1142, 'n_words': 301}