<commit_before>(ns puppetlabs.cthun.validation-test
  (:require [clojure.test :refer :all]
            [puppetlabs.cthun.validation :refer :all]
            [schema.core :as s]
            [slingshot.slingshot :refer [try+ throw+]]))

(deftest explode-uri-test
  (testing "It raises on invalid uris"
    (is (thrown? Exception (explode-uri ""))))
  (testing "It returns component chunks"
    (is (= [ "localhost" "agent"] (explode-uri "cth://localhost/agent")))
    (is (= [ "localhost" "*" ] (explode-uri "cth://localhost/*")))
    (is (= [ "*" "agent" ] (explode-uri "cth://*/agent")))))

(deftest validate-certname-test
  (testing "simple match, no exception"
    (try+
     (validate-certname "cth://lolcathost/agent" "lolcathost")
     (catch Object _
       (is (not true) "No exception should be raised"))
     (else (is true "No exception raised"))))
  (testing "simple mismatch"
    (try+
     (validate-certname "cth://lolcathost/agent" "remotecat")
     (catch map? m
       (is (= :puppet.cthun.validation/identity-invalid) (:type m)))
     (else (is (not true) "Expected an exception for remotecat"))))
  (testing "accidental regex collisions"
    (try+
     (validate-certname "cth://lolcathost/agent" "remotecat")
     (catch map? m
       (is (= :puppet.cthun.validation/identity-invalid) (:type m)))
     (else (is (not true) "Expected an exception for lol.athost")))))<commit_msg>(maint) fix validate-certname test<commit_after>(ns puppetlabs.cthun.validation-test
  (:require [clojure.test :refer :all]
            [puppetlabs.cthun.validation :refer :all]
            [schema.core :as s]
            [slingshot.slingshot :refer [try+ throw+]]))

(deftest explode-uri-test
  (testing "It raises on invalid uris"
    (is (thrown? Exception (explode-uri ""))))
  (testing "It returns component chunks"
    (is (= [ "localhost" "agent"] (explode-uri "cth://localhost/agent")))
    (is (= [ "localhost" "*" ] (explode-uri "cth://localhost/*")))
    (is (= [ "*" "agent" ] (explode-uri "cth://*/agent")))))

(deftest validate-certname-test
  (testing "simple match, no exception"
    (try+
     (validate-certname "cth://lolcathost/agent" "lolcathost")
     (catch Object _
       (is (not true) "No exception should be raised"))
     (else (is true "No exception raised"))))
  (testing "simple mismatch"
    (try+
     (validate-certname "cth://lolcathost/agent" "remotecat")
     (catch map? m
       (is (= :puppetlabs.cthun.validation/identity-invalid (:type m))))
     (else (is (not true) "Expected an exception for remotecat"))))
  (testing "accidental regex collisions"
    (try+
     (validate-certname "cth://lolcathost/agent" "remotecat")
     (catch map? m
       (is (= :puppetlabs.cthun.validation/identity-invalid (:type m))))
     (else (is (not true) "Expected an exception for lol.athost")))))
{'fraction_non_alphanumeric': 0.17238938053097344, 'fraction_numerical': 0.0, 'mean_word_length': 3.3410138248847927, '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': '7237433', 'n_tokens_mistral': 989, 'n_tokens_neox': 965, 'n_words': 242}