<commit_before>require 'spec_helper'
require 'delorean'

# Test authentication clients
describe Client do
  let(:domain_machers) { nil }
  let(:redirect_uris) { nil }
  let(:client) do
    Client.create(
      app_id: 'testing-client',
      app_secret: 'xyzzy',
      name: 'testing-client',
      site_url: 'http://localhost:8080/',
      domain_matchers: domain_machers,
      redirect_uris: redirect_uris
    )
  end
  context "a client that isn't restricted to various domains" do
    it "should validate from any domain" do
      expect(client).to be_valid_from_referer("http://blargonaut.com/")
      expect(client).to be_valid_from_referer("http://foo.com/blarg.html")
    end
  end
  context "a client that has domains matchers set to whitespace" do
    let(:domain_matchers) { "    \t\n   " }
    it "should validate from any domain" do
      expect(client).to be_valid_from_referer("http://blargonaut.com/")
      expect(client).to be_valid_from_referer("http://foo.com/blarg.html")
    end
  end
  context "a client that only works for foo.com or baz.com domains" do
    let(:domain_machers) { "foo.com baz.com" }
    it "should not validate for referers of blargonaut" do
      expect(client.valid_from_referer?("http://blargonaut.com/")).to be_falsey
      expect(client.valid_from_referer?("http://blargonaut.com/foo.com")).to be_falsey
      expect(client.valid_from_referer?("http://blargonaut.com/baz.com")).to be_falsey
    end
    it "should not validate if HTTP_REFERER is missing" do
      expect(client.valid_from_referer?("")).to be_falsey
    end
    it "should validate for referers of foo.com" do<commit_msg>Fix tiny typo in test.<commit_after>require 'spec_helper'
require 'delorean'

# Test authentication clients
describe Client do
  let(:domain_matchers) { nil }
  let(:redirect_uris) { nil }
  let(:client) do
    Client.create(
      app_id: 'testing-client',
      app_secret: 'xyzzy',
      name: 'testing-client',
      site_url: 'http://localhost:8080/',
      domain_matchers: domain_matchers,
      redirect_uris: redirect_uris
    )
  end
  context "a client that isn't restricted to various domains" do
    it "should validate from any domain" do
      expect(client).to be_valid_from_referer("http://blargonaut.com/")
      expect(client).to be_valid_from_referer("http://foo.com/blarg.html")
    end
  end
  context "a client that has domains matchers set to whitespace" do
    let(:domain_matchers) { "    \t\n   " }
    it "should validate from any domain" do
      expect(client).to be_valid_from_referer("http://blargonaut.com/")
      expect(client).to be_valid_from_referer("http://foo.com/blarg.html")
    end
  end
  context "a client that only works for foo.com or baz.com domains" do
    let(:domain_matchers) { "foo.com baz.com" }
    it "should not validate for referers of blargonaut" do
      expect(client.valid_from_referer?("http://blargonaut.com/")).to be_falsey
      expect(client.valid_from_referer?("http://blargonaut.com/foo.com")).to be_falsey
      expect(client.valid_from_referer?("http://blargonaut.com/baz.com")).to be_falsey
    end
    it "should not validate if HTTP_REFERER is missing" do
      expect(client.valid_from_referer?("")).to be_falsey
    end
    it "should validate for referers of foo.com" do
{'fraction_non_alphanumeric': 0.11669713589274833, 'fraction_numerical': 0.002437538086532602, 'mean_word_length': 3.5470914127423825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2992704', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1097, 'n_words': 263}