<commit_before>require 'rails_helper'

describe "Sessions Requests" do
  describe "POST /sessions" do
    before do
      create(:user, username: "test_user", password: "<PASSWORD>")
    end

    context "correct credentials" do
      it "signs in the user and returns a new token" do
        post_json "/sessions", { username: "test_user", password: "<PASSWORD>" }
        expect(last_response.status).to eq(200)
        expect(json["token"]).to be_a(String)
      end
    end

    context "incorrect credentials" do
      it "responds 401" do
        post_json "/sessions", { username: "test_user", password: "<PASSWORD>" }
        expect(last_response.status).to eq(401)
        expect(json["error_code"]).to eq("AUTHENTICATION_ERROR")
      end
    end
  end

  describe "GET /sessions/current" do
    before { auth }
<commit_msg>expect 403 for invalid credentials<commit_after>require 'rails_helper'

describe "Sessions Requests" do
  describe "POST /sessions" do
    before do
      create(:user, username: "test_user", password: "<PASSWORD>")
    end

    context "correct credentials" do
      it "signs in the user and returns a new token" do
        post_json "/sessions", { username: "test_user", password: "<PASSWORD>" }
        expect(last_response.status).to eq(200)
        expect(json["token"]).to be_a(String)
      end
    end

    context "incorrect credentials" do
      it "responds 401" do
        post_json "/sessions", { username: "test_user", password: "<PASSWORD>" }
        expect(last_response.status).to eq(403)
        expect(json["error_code"]).to eq("AUTHENTICATION_ERROR")
      end
    end
  end

  describe "GET /sessions/current" do
    before { auth }

{'fraction_non_alphanumeric': 0.1172291296625222, 'fraction_numerical': 0.012433392539964476, 'mean_word_length': 3.072289156626506, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7034221', 'n_tokens_mistral': 534, 'n_tokens_neox': 508, 'n_words': 148}