<commit_before>describe Validation::Rule::DiasporaId do
  it "will not accept parameters" do
    validator = Validation::Validator.new({})
    expect {
      validator.rule(:diaspora_id, diaspora_id: {param: true})
    }.to raise_error ArgumentError
  end

  it "has an error key" do
    expect(described_class.new.error_key).to eq(:diaspora_id)
  end

  context "validation" do
    it "validates a normal diaspora* ID" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with localhost" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@localhost"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with port" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>:3000"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with IPv4 address" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@172.16.58.3"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with IPv6 address" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@[2001:1234:5678:90ab:cdef::1]"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with . and -" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "fails if the diaspora* ID contains a / in the domain-name" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>/friendica"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).not_to be_valid
      expect(validator.errors).to include(:diaspora_id)
    end

    it "fails if the diaspora* ID contains a _ in the domain-name" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).not_to be_valid
      expect(validator.errors).to include(:diaspora_id)
    end

    it "fails if the diaspora* ID contains a special-chars in the username" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>$^<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).not_to be_valid
      expect(validator.errors).to include(:diaspora_id)
    end
<commit_msg>Add tests for not validating uppercase characters<commit_after>describe Validation::Rule::DiasporaId do
  it "will not accept parameters" do
    validator = Validation::Validator.new({})
    expect {
      validator.rule(:diaspora_id, diaspora_id: {param: true})
    }.to raise_error ArgumentError
  end

  it "has an error key" do
    expect(described_class.new.error_key).to eq(:diaspora_id)
  end

  context "validation" do
    it "validates a normal diaspora* ID" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with localhost" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@localhost"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with port" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>:3000"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with IPv4 address" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@172.16.58.3"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with IPv6 address" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@[2001:1234:5678:90ab:cdef::1]"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "validates a diaspora* ID with . and -" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).to be_valid
      expect(validator.errors).to be_empty
    end

    it "fails if the diaspora* ID contains a / in the domain-name" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>/friendica"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).not_to be_valid
      expect(validator.errors).to include(:diaspora_id)
    end

    it "fails if the diaspora* ID contains a _ in the domain-name" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).not_to be_valid
      expect(validator.errors).to include(:diaspora_id)
    end

    it "fails if the diaspora* ID contains a special-chars in the username" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user$^<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).not_to be_valid
      expect(validator.errors).to include(:diaspora_id)
    end

    it "fails if the diaspora* ID contains uppercase characters in the username" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).not_to be_valid
      expect(validator.errors).to include(:diaspora_id)
    end

    it "fails if the diaspora* ID contains uppercase characters in the domain-name" do
      validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "<EMAIL>"))
      validator.rule(:diaspora_id, :diaspora_id)

      expect(validator).not_to be_valid
      expect(validator.errors).to include(:diaspora_id)
    end

{'fraction_non_alphanumeric': 0.10999557064816182, 'fraction_numerical': 0.008563413553816625, 'mean_word_length': 3.8385714285714285, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3956118', 'n_tokens_mistral': 2417, 'n_tokens_neox': 2248, 'n_words': 468}