<commit_before>require 'rspectacular'
require 'chamber/filters/decryption_filter'

module    Chamber
module    Filters
describe  DecryptionFilter do
  it 'will attempt to decrypt values which are marked as "secure"' do
    filtered_settings = DecryptionFilter.execute(
      data:           {
        _secure_my_secure_setting: 'cJbFe0NI5wknmsp2fVgpC/YeBD2pvcdVD+p0pUdnMoYThaV4m' \
                                   'psspg/ZTBtmjx7kMwcF6cjXFLDVw3FxptTHwzJUd4akun6EZ5' \
                                   '7m+QzCMJYnfY95gB2/emEAQLSz4/YwsE4LDGydkEjY1ZprfXz' \
                                   'nf+rU31YGDJUTf34ESz7fsQGSc9DjkBb9ao8Mv4cI7pCXkQZD' \
                                   'wS5kLAZDf6agy1GzeL71Z8lrmQzk8QQuf/1kQzxsWVlzpKNXW' \
                                   'S7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1kK' \
                                   'TcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ==',
      },
      decryption_key: './spec/spec_key')

    expect(filtered_settings._secure_my_secure_setting).to eql 'hello'
  end

  it 'will not attempt to decrypt values which are not marked as "secure"' do
    filtered_settings = DecryptionFilter.execute(
      data:           {
        my_secure_setting: 'cJbFe0NI5wknmsp2fVgpC/YeBD2pvcdVD+p0pUdnMoYThaV4m' \
                           'psspg/ZTBtmjx7kMwcF6cjXFLDVw3FxptTHwzJUd4akun6EZ5' \
                           '7m+QzCMJYnfY95gB2/<KEY>/YwsE4LDGydkEjY1ZprfXz' \
                           'nf+rU31YGDJUTf34ESz7fsQGSc9DjkBb9ao8Mv4cI7pCXkQZD' \
                           'wS5kLAZDf6agy1GzeL71Z8lrmQzk8QQuf/1kQzxsWVlzpKNXW' \
                           'S7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1kK' \
                           'TcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBK<KEY> },
      decryption_key: './spec/spec_key')

    my_secure_setting = filtered_settings.my_secure_setting

    expect(my_secure_setting).to eql '<KEY>' \
                                     '<KEY>' \
                                     '<KEY>' \
                                     '<KEY>' \
                                     '<KEY>' \
                                     '<KEY>' \
                                     '<KEY>' \
                                     '+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ=='
  end

  it 'will not attempt to decrypt values even if they are prefixed with "secure"' do
    filtered_settings = DecryptionFilter.execute(
      data:           {
        secure_setting: '<KEY>' \
                        '<KEY>' \
                        '<KEY>' \
                        '<KEY>' \
                        '<KEY>' \
                        '<KEY>',
      },
      decryption_key: './spec/spec_key')

    secure_setting = filtered_settings.secure_setting

    expect(secure_setting).to eql '<KEY>' \
                                  '<KEY>' \
                                  '<KEY>' \
                                  '<KEY>' \
                                  '<KEY>NXW' \
                                  'S7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1kK' \
                                  'TcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ=='
  end

  it 'will not attempt to decrypt values even if they are not properly encoded' do
    filtered_settings = DecryptionFilter.execute(
      data:           {
        _secure_my_secure_setting: '<KEY>' \
                                   '<KEY>' \
                                   '<KEY>' \
                                   '<KEY>' \
                                   '<KEY>' \
                                   '<KEY>k' \
                                   'KTcdgbE9NcAhNr1+<KEY>0H1jPgGkBKQJKArfQ==',
      },
      decryption_key: './spec/spec_key')

    my_secure_setting = filtered_settings._secure_my_secure_setting

    expect(my_secure_setting).to eql '<KEY>' \
                                     '<KEY>' \
                                     '57m+QzCMJYnfY95gB2/emEAQLSz4/YwsE4LDGydkEjY1ZprfX' \
                                     'znf+rU31YGDJUTf34ESz7fsQGSc9DjkBb9ao8Mv4cI7pCXkQZ' \
                                     'DwS5kLAZDf6agy1GzeL71Z8lrmQzk8QQuf/1kQzxsWVlzpKNX' \
                                     'WS7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1k' \
                                     'KTcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ=='
  end

  it 'will not attempt to decrypt values if it guesses that they are not encrpyted' do
    filtered_settings = DecryptionFilter.execute(data:           {
                                                   _secure_my_secure_setting: 'hello' },
                                                 decryption_key: './spec/spec_key')

    expect(filtered_settings._secure_my_secure_setting).to eql 'hello'
  end

  it 'simply returns the encrypted string if there is no decryption key' do
    filtered_settings = DecryptionFilter.execute(
      data: {
        _secure_my_secure_setting: 'cJbFe0NI5\wknmsp2fVgpC/YeBD2pvcdVD+p0pUdnMoYThaV4' \
                                   '<KEY>' \
                                   '<KEY>' \
                                   '<KEY>' \
                                   '<KEY>pKNX' \
                                   'WS7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1k' \
                                   'KTcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ==',
      },
    )

    my_secure_setting = filtered_settings._secure_my_secure_setting

    expect(my_secure_setting).to eql 'cJbFe0NI5\wknmsp2fVgpC/YeBD2pvcdVD+p0pUdnMoYThaV4' \
                                     'mpsspg/ZTBtmjx7kMwcF6cjXFLDVw3FxptTHwzJUd4akun6EZ' \
                                     '<KEY>' \
                                     'znf+rU31YGDJUTf34ESz7fsQGSc9DjkBb9ao8Mv4cI7pCXkQZ' \
                                     'DwS5kLAZDf6agy1GzeL71Z8lrmQzk8QQuf/1kQzxsWVlzpKNX' \
                                     'WS7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1k' \
                                     'KTcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ=='
  end

  it 'can decrypt a complex object' do
    filtered_settings = DecryptionFilter.execute( data: {
                                                    _secure_my_secure_setting: 'rF1MIcLX/Q88gjpHTifI27fJHopDKVTJRvOwF2MZ8kVIrvBhFgLOyQ7JEBiWNBh1yUtR6PeKlB+h44sIL3yKMcZyccX73Mo+CiWxmnjtK4I1QxcJL8OSLa8GQPlSBxoBCykWqerwN0b2oS/jv8umB2j2RyANFYklD3mAxn1LsoTuFPAif+SCLRIGafcHkOywM32qn6HhUpeBChX81JhJpip1gdJmRTGEZjKfR93h1shW0LqLLbdQUwYPOPbnjz7fU7x+d5/ighWTDsmOVyvEiqM0WasFzK+WBUfvo8tQxUymexw/U3B7N/0R/9v6U3l6x7eeIoQ4+lnJK2ULFzVgiw==' },
                                                  decryption_key: './spec/spec_key' )

    expect(filtered_settings._secure_my_secure_setting).to be_a Integer
    expect(filtered_settings._secure_my_secure_setting).to eql  12345
  end
end
end
end<commit_msg>Tests: Add test for number not in YAML format<commit_after>require 'rspectacular'
require 'chamber/filters/decryption_filter'

module    Chamber
module    Filters
describe  DecryptionFilter do
  it 'will attempt to decrypt values which are marked as "secure"' do
    filtered_settings = DecryptionFilter.execute(
      data:           {
        _secure_my_secure_setting: '<KEY>/<KEY>' \
                                   '<KEY>' \
                                   '7m+QzCMJYnfY95gB2/emEAQLSz4/YwsE4LDGydkEjY1ZprfXz' \
                                   'nf+rU31YGDJUTf34ESz7fsQGSc9DjkBb9ao8Mv4cI7pCXkQZD' \
                                   'wS5kLAZDf6agy1GzeL71Z8lrmQzk8QQuf/1kQzxsWVlzpKNXW' \
                                   'S7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1kK' \
                                   'TcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ==',
      },
      decryption_key: './spec/spec_key')

    expect(filtered_settings._secure_my_secure_setting).to eql 'hello'
  end

  it 'will not attempt to decrypt values which are not marked as "secure"' do
    filtered_settings = DecryptionFilter.execute(
      data:           {
        my_secure_setting: '<KEY>' \
                           '<KEY>' \
                           '<KEY>' \
                           '<KEY>' \
                           '<KEY>' \
                           '<KEY>' \
                           '<KEY> },
      decryption_key: './spec/spec_key')

    my_secure_setting = filtered_settings.my_secure_setting

    expect(my_secure_setting).to eql '<KEY>' \
                                     '<KEY>' \
                                     'd4akun6EZ57m+QzCMJYnfY95gB2/<KEY>L' \
                                     'DGydkEjY1ZprfXznf+rU31YGDJUTf34ESz7fsQGSc9Dj' \
                                     'kBb9ao8Mv4cI7pCXkQZDwS5kLAZDf6agy1GzeL71Z8lr' \
                                     'mQzk8QQuf/1kQzxsWVlzpKNXWS7u2CJ0sN5eINMngJBf' \
                                     'v5ZFrZgfXc86wdgUKc8aaoX8OQA1kKTcdgbE9NcAhNr1' \
                                     '+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ=='
  end

  it 'will not attempt to decrypt values even if they are prefixed with "secure"' do
    filtered_settings = DecryptionFilter.execute(
      data:           {
        secure_setting: '<KEY>' \
                        '<KEY>' \
                        '<KEY>' \
                        '<KEY>' \
                        '<KEY>' \
                        'cdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ==',
      },
      decryption_key: './spec/spec_key')

    secure_setting = filtered_settings.secure_setting

    expect(secure_setting).to eql '<KEY>' \
                                  'psspg/<KEY>' \
                                  '<KEY>gB2/emEAQLSz4/YwsE4LDGydkEjY1ZprfXz' \
                                  'nf+rU31YGDJUTf34ESz7fsQGSc9DjkBb9ao8Mv4cI7pCXkQZD' \
                                  '<KEY>' \
                                  '<KEY>K' \
                                  '<KEY>
  end

  it 'will not attempt to decrypt values even if they are not properly encoded' do
    filtered_settings = DecryptionFilter.execute(
      data:           {
        _secure_my_secure_setting: '<KEY>' \
                                   '<KEY>' \
                                   '<KEY>' \
                                   '<KEY>' \
                                   'DwS5kLAZDf6agy1GzeL71Z8lrmQzk8QQuf/<KEY>NX' \
                                   'WS7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1k' \
                                   'KTcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ==',
      },
      decryption_key: './spec/spec_key')

    my_secure_setting = filtered_settings._secure_my_secure_setting

    expect(my_secure_setting).to eql 'cJbFe0NI5\wknmsp2fVgpC/YeBD2pvcdVD+p0pUdnMoYThaV4' \
                                     '<KEY>' \
                                     '<KEY>' \
                                     '<KEY>' \
                                     'DwS5kLAZDf6agy1GzeL71Z8lrmQzk8QQuf/1kQzxsWVlzpKNX' \
                                     '<KEY>' \
                                     '<KEY>
  end

  it 'will not attempt to decrypt values if it guesses that they are not encrpyted' do
    filtered_settings = DecryptionFilter.execute(data:           {
                                                   _secure_my_secure_setting: 'hello' },
                                                 decryption_key: './spec/spec_key')

    expect(filtered_settings._secure_my_secure_setting).to eql 'hello'
  end

  it 'simply returns the encrypted string if there is no decryption key' do
    filtered_settings = DecryptionFilter.execute(
      data: {
        _secure_my_secure_setting: 'cJbFe0NI5\wknmsp2fVgpC/YeBD2pvcdVD+p0pUdnMoYThaV4' \
                                   'mpsspg/ZTBtmjx7kMwcF6cjXFLDVw3FxptTHwzJUd4akun6EZ' \
                                   '57m+QzCMJYnfY95gB2/emEAQLSz4/YwsE4LDGydkEjY1ZprfX' \
                                   'znf+rU31YGDJUTf34ESz7fsQGSc9DjkBb9ao8Mv4cI7pCXkQZ' \
                                   'DwS5kLAZDf6agy1GzeL71Z8lrmQzk8QQuf/1kQzxsWVlzpKNX' \
                                   'WS7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1k' \
                                   'KTcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ==',
      },
    )

    my_secure_setting = filtered_settings._secure_my_secure_setting

    expect(my_secure_setting).to eql 'cJbFe0NI5\wknmsp2fVgpC/YeBD2pvcdVD+p0pUdnMoYThaV4' \
                                     '<KEY>' \
                                     '<KEY>' \
                                     '<KEY>' \
                                     '<KEY>f/1kQzxsWVlzpKNX' \
                                     'WS7u2CJ0sN5eINMngJBfv5ZFrZgfXc86wdgUKc8aaoX8OQA1k' \
                                     'KTcdgbE9NcAhNr1+WfNxMnz84XzmUp2Y0H1jPgGkBKQJKArfQ=='
  end

  it 'can decrypt a complex object' do
    filtered_settings = DecryptionFilter.execute( data: {
                                                    _secure_my_secure_setting: '<KEY> },
                                                  decryption_key: './spec/spec_key' )

    expect(filtered_settings._secure_my_secure_setting).to be_a Integer
    expect(filtered_settings._secure_my_secure_setting).to eql  12345
  end

  it 'can decrypt a number that has not been yamlled' do
    filtered_settings = DecryptionFilter.execute( data: {
                                                    _secure_my_secure_setting: 'Ieh5poOpcirj1jihkh1eENaCrF8ECQSLOigM4ApTZ8hp4vrL3NKWp3djEkQz0QceopgN8TBJOEj1lqfGGL3Ar5L0SGrIsHt6KOilerEXXH4/e2+s8JFWpdfjCxgn12fv1jqXxNyuMUlYRBD7R+oRNVA5nNpnwiSE7IOBjUEZyzlQUrePVku5CtOs0hfGe+79n6D8zFGTpx7UjZg4QVXyHISBM2hAaDOZ0dfxVqbzmvN3B68xbuIty5vyv1+Ry2k+yIGJXIOjNm96ntDxIuUbycfrqYdtopBDI5kcr0zckPWMQRqkp7yd/XNZqyYCFGMNKNwokE6wZuGffkD/H/VPxQ==' },
                                                  decryption_key: './spec/spec_key')

    expect(filtered_settings._secure_my_secure_setting).to eql '12345'
  end
end
end
end
{'fraction_non_alphanumeric': 0.07268260963803193, 'fraction_numerical': 0.04190448667003829, 'mean_word_length': 1.429699842022117, 'pattern_counts': {'":': 0, '<': 76, '<?xml version=': 0, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 106, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4037239', 'n_tokens_mistral': 5422, 'n_tokens_neox': 5050, 'n_words': 519}