<commit_before>(ns puppetlabs.trapperkeeper.services.status.status-proxy-service-test
  (:require [clojure.test :refer :all]
    [cheshire.core :as json]
    [schema.test :as schema-test]
    [puppetlabs.http.client.sync :as http-client]
    [puppetlabs.trapperkeeper.core :refer [defservice service]]
    [puppetlabs.trapperkeeper.testutils.bootstrap :refer :all]
    [puppetlabs.trapperkeeper.testutils.logging :refer [with-test-logging]]
    [puppetlabs.trapperkeeper.services.status.status-service :refer [status-service]]
    [puppetlabs.trapperkeeper.services.status.status-proxy-service :refer [status-proxy-service]]
    [puppetlabs.trapperkeeper.services.status.status-core :as status-core]
    [puppetlabs.trapperkeeper.services.webrouting.webrouting-service :as webrouting-service]
    [puppetlabs.trapperkeeper.services.webserver.jetty9-service :as jetty9-service]))

(use-fixtures :once schema-test/validate-schemas)

(def dev-resources "./dev-resources/puppetlabs/trapperkeeper-status/status-proxy-service-test")
(def common-ssl-config
  {:ssl-cert    (str dev-resources "/ssl/certs/localhost.pem")
   :ssl-key     (str dev-resources "/ssl/private_keys/localhost.pem")
   :ssl-ca-cert (str dev-resources "/ssl/certs/ca.pem")})

(def ssl-status-service-config
  {:webserver (merge common-ssl-config
                {:ssl-host "0.0.0.0"
                 :ssl-port 9001})
   :web-router-service {:puppetlabs.trapperkeeper.services.status.status-service/status-service "/ssl-status"}})

(def status-proxy-service-config
  {:webserver          {:port 8181
                        :host "0.0.0.0"}
   :status-proxy       {:proxy-target-url "https://0.0.0.0:9001/ssl-status"
                        :ssl-opts common-ssl-config}
   :web-router-service {:puppetlabs.trapperkeeper.services.status.status-proxy-service/status-proxy-service "/status-proxy"}})


(defservice foo-service
  [[:StatusService register-status]]
  (init [this context]
    (register-status "foo" "1.1.0" 1 (fn [level] {:status (str "foo status 1 " level)
                                                  :state :running}))<commit_msg>(MAINT) Attempt to fix 502 failures in tests<commit_after>(ns puppetlabs.trapperkeeper.services.status.status-proxy-service-test
  (:require [clojure.test :refer :all]
    [cheshire.core :as json]
    [schema.test :as schema-test]
    [puppetlabs.http.client.sync :as http-client]
    [puppetlabs.trapperkeeper.core :refer [defservice service]]
    [puppetlabs.trapperkeeper.testutils.bootstrap :refer :all]
    [puppetlabs.trapperkeeper.testutils.logging :refer [with-test-logging]]
    [puppetlabs.trapperkeeper.services.status.status-service :refer [status-service]]
    [puppetlabs.trapperkeeper.services.status.status-proxy-service :refer [status-proxy-service]]
    [puppetlabs.trapperkeeper.services.status.status-core :as status-core]
    [puppetlabs.trapperkeeper.services.webrouting.webrouting-service :as webrouting-service]
    [puppetlabs.trapperkeeper.services.webserver.jetty9-service :as jetty9-service]))

(use-fixtures :once schema-test/validate-schemas)

(def dev-resources "./dev-resources/puppetlabs/trapperkeeper-status/status-proxy-service-test")
(def common-ssl-config
  {:ssl-cert    (str dev-resources "/ssl/certs/localhost.pem")
   :ssl-key     (str dev-resources "/ssl/private_keys/localhost.pem")
   :ssl-ca-cert (str dev-resources "/ssl/certs/ca.pem")})

(def ssl-status-service-config
  {:webserver (merge common-ssl-config
                {:ssl-host "0.0.0.0"
                 :ssl-port 9001})
   :web-router-service {:puppetlabs.trapperkeeper.services.status.status-service/status-service "/ssl-status"}})

(def status-proxy-service-config
  {:webserver          {:port 8181
                        :host "0.0.0.0"}
   :status-proxy       {:proxy-target-url "https://localhost:9001/ssl-status"
                        :ssl-opts common-ssl-config}
   :web-router-service {:puppetlabs.trapperkeeper.services.status.status-proxy-service/status-proxy-service "/status-proxy"}})


(defservice foo-service
  [[:StatusService register-status]]
  (init [this context]
    (register-status "foo" "1.1.0" 1 (fn [level] {:status (str "foo status 1 " level)
                                                  :state :running}))
{'fraction_non_alphanumeric': 0.1424548228115466, 'fraction_numerical': 0.014315888289134006, 'mean_word_length': 3.3007063572149344, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7252262', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1421, 'n_words': 222}