<commit_before>require 'test_helper'
require "base64"

class ApiAuthenticationTest < ActionDispatch::IntegrationTest

  def setup
    @user = FactoryGirl.create :user, email: '<EMAIL>', authentication_token: '<PASSWORD>'
  end

  test "Unauthorised user tries to create a dataset" do
    cert = FactoryGirl.create(:published_certificate_with_dataset)
    post "/datasets", {}, {"HTTP_AUTHORIZATION" => "Basic "+Base64.encode64('<EMAIL>:test123').gsub(/\n/, '')}
    assert_response :unauthorized
  end

  test "Authorised user tries to create a dataset" do
    cert = FactoryGirl.create(:published_certificate_with_dataset)
    post "/datasets", {}, {"HTTP_AUTHORIZATION" => "Basic "+Base64.encode64('<EMAIL>:test1234').gsub(/\n/, '')}
    assert_response :success
  end
end<commit_msg>update test<commit_after>require 'test_helper'
require "base64"

class ApiAuthenticationTest < ActionDispatch::IntegrationTest

  def setup
    @user = FactoryGirl.create :user, email: '<EMAIL>', authentication_token: '<PASSWORD>'
  end

  test "Unauthorised user tries to create a dataset" do
    cert = FactoryGirl.create(:published_certificate_with_dataset)
    post "/datasets", {}, {"HTTP_AUTHORIZATION" => "Basic "+Base64.encode64('<EMAIL>:test123').gsub(/\n/, '')}
    assert_response :unauthorized
  end

  test "Authorised user tries to create a dataset" do
    cert = FactoryGirl.create(:published_certificate_with_dataset)
    post "/datasets", {}, {"HTTP_AUTHORIZATION" => "Basic "+Base64.encode64('<EMAIL>:test1234').gsub(/\n/, '')}
    assert_response :unprocessable_entity
  end
end
{'fraction_non_alphanumeric': 0.13644977890082122, 'fraction_numerical': 0.02147820593809223, 'mean_word_length': 5.336, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '6335046', 'n_tokens_mistral': 506, 'n_tokens_neox': 477, 'n_words': 112}