<commit_before>require 'spec_helper'

describe OmniAuth::Strategies::Dnb do

  PRIVATE_KEY_FILE = File.join RSpec.configuration.cert_folder, 'bank.key'
  PUBLIC_KEY_FILE = File.join RSpec.configuration.cert_folder, 'bank.crt'

  let(:app){ Rack::Builder.new do |b|
    b.use Rack::Session::Cookie, { secret: 'abc123'}
    b.use(OmniAuth::Strategies::Dnb, PRIVATE_KEY_FILE, PUBLIC_KEY_FILE, 'MY_SND_ID')
    b.run lambda{|env| [404, {}, ['Not Found']]}
  end.to_app }

  let(:private_key) { OpenSSL::PKey::RSA.new(File.read(PRIVATE_KEY_FILE)) }
  let(:public_key)  { OpenSSL::PKey::RSA.new(File.read(PUBLIC_KEY_FILE)) }
  let(:last_response_stamp) { last_response.body.match(/name="VK_STAMP" value="([^"]*)"/)[1] }
  let(:last_response_mac)   { last_response.body.match(/name="VK_MAC" value="([^"]*)"/)[1] }

  context 'request phase' do
    before(:each){ get '/auth/dnb' }

    it 'displays a single form' do
      expect(last_response.status).to eq(200)
      expect(last_response.body.scan('<form').size).to eq(1)
    end

    it 'has JavaScript code to submit the form after it is created' do
      expect(last_response.body).to be_include("</form><script type=\"text/javascript\">document.forms[0].submit();</script>")
    end

    EXPECTED_VALUES = {
      VK_SERVICE: '3001',
      VK_VERSION: '101',
      VK_SND_ID:  'MY_SND_ID',
      VK_RETURN:  'http://example.org/auth/dnb/callback'
    }

    EXPECTED_VALUES.each_pair do |k,v|
      it 'has hidden input field #{k} => #{v}' do<commit_msg>Small improvements<commit_after>require 'spec_helper'

describe OmniAuth::Strategies::Dnb do

  PRIVATE_KEY_FILE = File.join RSpec.configuration.cert_folder, 'bank.key'
  PUBLIC_KEY_FILE = File.join RSpec.configuration.cert_folder, 'bank.crt'

  let(:app){ Rack::Builder.new do |b|
    b.use Rack::Session::Cookie, { secret: 'abc123'}
    b.use(OmniAuth::Strategies::Dnb, PRIVATE_KEY_FILE, PUBLIC_KEY_FILE, 'MY_SND_ID')
    b.run lambda{|env| [404, {}, ['Not Found']]}
  end.to_app }

  let(:private_key) { OpenSSL::PKey::RSA.new(File.read(PRIVATE_KEY_FILE)) }
  let(:public_key)  { OpenSSL::PKey::RSA.new(File.read(PUBLIC_KEY_FILE)) }
  let(:last_response_stamp) { last_response.body.match(/name="VK_STAMP" value="([^"]*)"/)[1] }
  let(:last_response_mac)   { last_response.body.match(/name="VK_MAC" value="([^"]*)"/)[1] }

  context 'request phase' do
    before(:each){ get '/auth/dnb' }

    it 'displays a single form' do
      expect(last_response.status).to eq(200)
      expect(last_response.body.scan('<form').size).to eq(1)
    end

    it 'has JavaScript code to submit the form after it is created' do
      expect(last_response.body).to be_include('</form><script type="text/javascript">document.forms[0].submit();</script>')
    end

    EXPECTED_VALUES = {
      VK_SERVICE: '3001',
      VK_VERSION: '101',
      VK_SND_ID:  'MY_SND_ID',
      VK_RETURN:  'http://example.org/auth/dnb/callback'
    }

    EXPECTED_VALUES.each_pair do |k,v|
      it 'has hidden input field #{k} => #{v}' do
{'fraction_non_alphanumeric': 0.17082087072116983, 'fraction_numerical': 0.013293452974410104, 'mean_word_length': 4.2622377622377625, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5984435', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1120, 'n_words': 192}