<commit_before>require 'rack/builder'
require 'yaml'
require 'picnic/conf'
require 'fileutils'
require 'active_record' # see below
require File.expand_path("../controllable_rack_server.rb", __FILE__)

# Because rubycas-server's config.ru refers to the Rack module, it
# needs to be interpreted outside of the Bcsec module.
module CASServer
  def self.app(config_filename)
    $CONF = Picnic::Conf.new
    $CONF.load_from_file(nil, nil, config_filename)

    rackup = File.expand_path("../config.ru",
                              $LOAD_PATH.detect { |path| path =~ /rubycas-server/ })
    app = ::Rack::Builder.new.instance_eval(File.read(rackup))
  end
end

module Bcsec
  module Cucumber
    class ControllableCasServer < ControllableRackServer
      include FileUtils

      attr_reader :users_database_filename

      def initialize(tmpdir, port)
        super(:port => port, :tmpdir => tmpdir, :ssl => false, :app_creator => lambda {
                CASServer.app(create_server_config(binding))
              })
      end

      def start
        @users_database_filename = create_user_database
        super
      end

      def stop
        PrivateModel.connection_handler.clear_all_connections!
        super
      end

      def register_user(username, password)
        PrivateModel.connection.
          update("INSERT INTO users (username, password) VALUES ('#{username}', '#{password}')")
      end

      protected

      def log_filename
        "cas-out.log"
      end

      private

      def active_record_adapter<commit_msg>Use SSL when testing CAS servers.<commit_after>require 'rack/builder'
require 'yaml'
require 'picnic/conf'
require 'fileutils'
require 'active_record' # see below
require File.expand_path("../controllable_rack_server.rb", __FILE__)

# Because rubycas-server's config.ru refers to the Rack module, it
# needs to be interpreted outside of the Bcsec module.
module CASServer
  def self.app(config_filename)
    $CONF = Picnic::Conf.new
    $CONF.load_from_file(nil, nil, config_filename)

    rackup = File.expand_path("../config.ru",
                              $LOAD_PATH.detect { |path| path =~ /rubycas-server/ })
    app = ::Rack::Builder.new.instance_eval(File.read(rackup))
  end
end

module Bcsec
  module Cucumber
    class ControllableCasServer < ControllableRackServer
      include FileUtils

      attr_reader :users_database_filename

      def initialize(tmpdir, port)
        super(:port => port, :tmpdir => tmpdir, :ssl => true, :app_creator => lambda {
                CASServer.app(create_server_config(binding))
              })
      end

      def start
        @users_database_filename = create_user_database
        super
      end

      def stop
        PrivateModel.connection_handler.clear_all_connections!
        super
      end

      def register_user(username, password)
        PrivateModel.connection.
          update("INSERT INTO users (username, password) VALUES ('#{username}', '#{password}')")
      end

      protected

      def log_filename
        "cas-out.log"
      end

      private

      def active_record_adapter
{'fraction_non_alphanumeric': 0.09301577084003862, 'fraction_numerical': 0.0, 'mean_word_length': 2.758162031438936, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6529899', 'n_tokens_mistral': 933, 'n_tokens_neox': 883, 'n_words': 220}