<commit_before># frozen_string_literal: true

require "rspec/rails"

VCR.configure do |c|
  c.configure_rspec_metadata!
  c.cassette_library_dir = "spec/support/cassettes"

  c.default_cassette_options = {
    serialize_with: :json,
    preserve_exact_body_bytes:  true,
    decode_compressed_response: true,
    record: ENV["TRAVIS"] ? :none : :once
  }

  # Application id
  c.filter_sensitive_data("<TEST_APPLICATION_GITHUB_CLIENT_ID>") do
    application_github_client_id
  end

  c.filter_sensitive_data("<TEST_APPLICATION_GITHUB_CLIENT_SECRET>") do
    application_github_client_secret
  end

  # Owner
  c.filter_sensitive_data("<TEST_CLASSROOM_OWNER_GITHUB_ID>") do
    classroom_owner_github_id
  end

  c.filter_sensitive_data("<TEST_CLASSROOM_OWNER_GITHUB_TOKEN>") do
    classroom_owner_github_token
  end

  # Owners Org
  c.filter_sensitive_data("<TEST_CLASSROOM_OWNER_ORGANIZATION_GITHUB_ID>") do
    classroom_owner_organization_github_id
  end

  c.filter_sensitive_data("<TEST_CLASSROOM_OWNER_ORGANIZATION_GITHUB_LOGIN>") do
    classroom_owner_organization_github_login
  end

  # Student
  c.filter_sensitive_data("<TEST_CLASSROOM_STUDENT_GITHUB_ID>") do
    classroom_student_github_id
  end

  c.filter_sensitive_data("<TEST_CLASSROOM_STUDENT_GITHUB_TOKEN>") do
    classroom_student_github_token
  end

  c.hook_into :webmock
end

def application_github_client_id
  ENV.fetch("GITHUB_CLIENT_ID") { "i" * 20 }
end

def application_github_client_secret
  ENV.fetch("GITHUB_CLIENT_SECRET") { "r" * 20 }
end

def classroom_owner_github_id
  ENV.fetch("TEST_CLASSROOM_OWNER_GITHUB_ID") { 8_675_309 }
end

def classroom_owner_github_token
  ENV.fetch("TEST_CLASSROOM_OWNER_GITHUB_TOKEN") { "x" * 40 }
end

def classroom_owner_organization_github_id
  ENV.fetch("TEST_CLASSROOM_OWNER_ORGANIZATION_GITHUB_ID") { 1 }
end

def classroom_owner_organization_github_login
  ENV.fetch("TEST_CLASSROOM_OWNER_ORGANIZATION_GITHUB_LOGIN") { "classroom-testing-org" }
end

def classroom_student_github_id<commit_msg>Remove Authorization headers for VCR cassettes<commit_after># frozen_string_literal: true

require "rspec/rails"

VCR.configure do |c|
  c.configure_rspec_metadata!
  c.cassette_library_dir = "spec/support/cassettes"

  c.default_cassette_options = {
    serialize_with: :json,
    preserve_exact_body_bytes:  true,
    decode_compressed_response: true,
    record: ENV["TRAVIS"] ? :none : :once
  }

  c.before_record { |i| i.request.headers.delete "Authorization" }

  # Application id
  c.filter_sensitive_data("<TEST_APPLICATION_GITHUB_CLIENT_ID>") do
    application_github_client_id
  end

  c.filter_sensitive_data("<TEST_APPLICATION_GITHUB_CLIENT_SECRET>") do
    application_github_client_secret
  end

  # Owner
  c.filter_sensitive_data("<TEST_CLASSROOM_OWNER_GITHUB_ID>") do
    classroom_owner_github_id
  end

  # Owners Org
  c.filter_sensitive_data("<TEST_CLASSROOM_OWNER_ORGANIZATION_GITHUB_ID>") do
    classroom_owner_organization_github_id
  end

  c.filter_sensitive_data("<TEST_CLASSROOM_OWNER_ORGANIZATION_GITHUB_LOGIN>") do
    classroom_owner_organization_github_login
  end

  # Student
  c.filter_sensitive_data("<TEST_CLASSROOM_STUDENT_GITHUB_ID>") do
    classroom_student_github_id
  end

  c.hook_into :webmock
end

def application_github_client_id
  ENV.fetch("GITHUB_CLIENT_ID") { "i" * 20 }
end

def application_github_client_secret
  ENV.fetch("GITHUB_CLIENT_SECRET") { "r" * 20 }
end

def classroom_owner_github_id
  ENV.fetch("TEST_CLASSROOM_OWNER_GITHUB_ID") { 8_675_309 }
end

def classroom_owner_github_token
  ENV.fetch("TEST_CLASSROOM_OWNER_GITHUB_TOKEN") { "x" * 40 }
end

def classroom_owner_organization_github_id
  ENV.fetch("TEST_CLASSROOM_OWNER_ORGANIZATION_GITHUB_ID") { 1 }
end

def classroom_owner_organization_github_login
  ENV.fetch("TEST_CLASSROOM_OWNER_ORGANIZATION_GITHUB_LOGIN") { "classroom-testing-org" }
end

def classroom_student_github_id
{'fraction_non_alphanumeric': 0.07855138995154297, 'fraction_numerical': 0.00714103545014027, 'mean_word_length': 6.222836095764273, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5174651', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1500, 'n_words': 196}