<commit_before>require 'http/auth'

describe HTTP::Auth::TokenAuthorizationHeader do
  describe 'given a complete token authorization header' do
    let :complete_header_string do
      <<-EOS
        token="5ccc069c403ebaf9f0171e9517f40e41",
        coverage="base",
        nonce="2e0d73708933eff3e53319d884a0505c",
        auth="<PASSWORD>",
        timestamp="1234567890"
      EOS
    end

    let :complete_header do
      HTTP::Auth::TokenAuthorizationHeader.parse(complete_header_string)
    end

    it 'returns token as the schema' do
      expect(complete_header.schema).to eq(:token)
    end

    it 'returns the "token" attribute' do
      expect(complete_header.token).to eq('5ccc069c403ebaf9f0171e9517f40e41')
    end

    it 'returns the "coverage" attribute' do
      expect(complete_header.coverage).to eq('base')
    end

    it 'returns the "nonce" attribute' do
      expect(complete_header.nonce).to eq('2e0d73708933eff3e53319d884a0505c')
    end

    it 'returns the "auth" attribute' do
      expect(complete_header.auth).to eq('<PASSWORD>')
    end

    it 'returns the timestamp attribute' do
      expect(complete_header.timestamp).to eq('1234567890')
    end
  end

  describe 'given an incomplete token authorization header' do
    it 'fails if the "token" attribute is ommited' do
      without_token = 'coverage="base", nonce="2<PASSWORD>4a0<PASSWORD>c"'
      expect do
        HTTP::Auth::TokenAuthorizationHeader.parse without_token
      end.to raise_error(ArgumentError)
    end

    it 'fails if the "token" attribute is empty' do
      with_empty_token = 'token="", coverage="base", nonce="2e0d73708933eff3e53319d884a0505c"'
      expect do
        HTTP::Auth::TokenAuthorizationHeader.parse with_empty_token
      end.to raise_error(ArgumentError)
    end

    it 'returns "base" if the "coverage" attribute is ommited' do
      without_coverage = 'token="<PASSWORD>"'
      header = HTTP::Auth::TokenAuthorizationHeader.parse without_coverage
      expect(header.coverage).to eq('base')
    end

    it 'returns "base" if the "coverage" attribute is empty' do
      with_empty_coverage = 'token="<PASSWORD>", coverage=""'
      header = HTTP::Auth::TokenAuthorizationHeader.parse with_empty_coverage
      expect(header.coverage).to eq('base')
    end
  end
end<commit_msg>Improving code coverage<commit_after>require 'http/auth'

describe HTTP::Auth::TokenAuthorizationHeader do
  describe 'given a complete token authorization header' do
    let :complete_header_string do
      <<-EOS
        token="5ccc069c403ebaf9f0171e9517f40e41",
        coverage="foobar",
        nonce="2e0d73708933eff3e53319d884a0505c",
        auth="<PASSWORD>",
        timestamp="1234567890"
      EOS
    end

    let :complete_header do
      HTTP::Auth::TokenAuthorizationHeader.parse(complete_header_string)
    end

    it 'returns token as the schema' do
      expect(complete_header.schema).to eq(:token)
    end

    it 'returns the "token" attribute' do
      expect(complete_header.token).to eq('5ccc069c403ebaf9f0171e9517f40e41')
    end

    it 'returns the "coverage" attribute' do
      expect(complete_header.coverage).to eq('foobar')
    end

    it 'returns the "nonce" attribute' do
      expect(complete_header.nonce).to eq('2e0d73708933eff3e53319d884a0505c')
    end

    it 'returns the "auth" attribute' do
      expect(complete_header.auth).to eq('ed5a137d3724ec12ddd95bbea3e8a634')
    end

    it 'returns the "timestamp" attribute' do
      expect(complete_header.timestamp).to eq('1234567890')
    end
  end

  describe 'given an incomplete token authorization header' do
    it 'fails if the "token" attribute is ommited' do
      without_token = 'coverage="base", nonce="2e0d73708933eff3e53319d884a0505c"'
      expect do
        HTTP::Auth::TokenAuthorizationHeader.parse without_token
      end.to raise_error(ArgumentError)
    end

    it 'fails if the "token" attribute is empty' do
      with_empty_token = 'token="", coverage="base", nonce="2e0d73708933eff3e53319d884a0505c"'
      expect do
        HTTP::Auth::TokenAuthorizationHeader.parse with_empty_token
      end.to raise_error(ArgumentError)
    end

    it 'returns "base" if the "coverage" attribute is ommited' do
      without_coverage = 'token="<PASSWORD>"'
      header = HTTP::Auth::TokenAuthorizationHeader.parse without_coverage
      expect(header.coverage).to eq('base')
    end

    it 'returns "base" if the "coverage" attribute is empty' do
      with_empty_coverage = 'token="<PASSWORD>", coverage=""'
      header = HTTP::Auth::TokenAuthorizationHeader.parse with_empty_coverage
      expect(header.coverage).to eq('base')
    end

    it 'returns nil if the "nonce" attribute is ommited' do
      without_nonce = 'token="123123342"'
      header = HTTP::Auth::TokenAuthorizationHeader.parse without_nonce
      expect(header.nonce).to be_nil
    end

    it 'returns nil if the "auth" attribute is ommited' do
      without_auth = 'token="<PASSWORD>"'
      header = HTTP::Auth::TokenAuthorizationHeader.parse without_auth
      expect(header.auth).to be_nil
    end

    it 'returns nil if the "timestamp" attribute is ommited' do
      without_timestamp = 'token="<PASSWORD>"'
      header = HTTP::Auth::TokenAuthorizationHeader.parse without_timestamp
      expect(header.timestamp).to be_nil
    end
  end
end
{'fraction_non_alphanumeric': 0.09653882132834425, 'fraction_numerical': 0.057998129092609915, 'mean_word_length': 3.644656820156386, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 14, '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': '5622237', 'n_tokens_mistral': 1857, 'n_tokens_neox': 1665, 'n_words': 397}