iilyak commented on a change in pull request #2007: Port javascript tests auth cache, cookie auth and users db to elixir URL: https://github.com/apache/couchdb/pull/2007#discussion_r295914378
########## File path: test/elixir/test/auth_cache_test.exs ########## @@ -0,0 +1,215 @@ +defmodule AuthCacheTest do + use CouchTestCase + + @moduletag :authentication + @tag :with_db + test "test auth cache management", context do + db_name = context[:db_name] + + server_config = [ + %{ + :section => "chttpd_auth", + :key => "authentication_db", + :value => db_name + }, + %{ + :section => "chttpd_auth", + :key => "auth_cache_size", + :value => "3" + }, + %{ + :section => "httpd", + :key => "authentication_handlers", + :value => "{couch_httpd_auth, default_authentication_handler}" + }, + %{ + :section => "chttpd_auth", + :key => "secret", + :value => generate_secret(64) + } + ] + + run_on_modified_server(server_config, fn -> test_fun(db_name) end) + end + + defp generate_secret(length) do + tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + + for _i <- 1..length, into: "" do Review comment: This function can be written differently: ``` defp generate_secret(len) do tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' Enum.take_random(tab, len) end ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services