5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 04:16:22 +00:00
panel/test/controllers/api/v1/sites_controller_test.rb

41 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2019-09-05 18:56:24 +00:00
# frozen_string_literal: true
require 'test_helper'
module Api
module V1
class SitesControllerTest < ActionDispatch::IntegrationTest
setup do
@rol = create :rol
@site = @rol.site
@usuarie = @rol.usuarie
@authorization = {
Authorization: ActionController::HttpAuthentication::Basic
2019-09-06 23:40:33 +00:00
.encode_credentials(ENV['HTTP_BASIC_USER'],
ENV['HTTP_BASIC_PASSWORD'])
2019-09-05 18:56:24 +00:00
}
end
teardown do
@site.destroy
end
test 'se puede generar un certificado' do
2019-09-06 23:40:33 +00:00
get v1_sites_allowed_url, headers: @authorization,
params: { domain: @site.name }
2019-09-05 18:56:24 +00:00
assert_response :ok
2019-09-06 23:40:33 +00:00
get v1_sites_allowed_url, headers: @authorization,
params: { domain: SecureRandom.hex }
2019-09-05 18:56:24 +00:00
assert_response :not_found
end
2019-09-06 23:40:33 +00:00
test 'se puede obtener un listado de todos' do
get v1_sites_url, headers: @authorization, as: :json
assert_equal Site.all.pluck(:name), JSON.parse(response.body)
2019-09-06 23:40:33 +00:00
end
2019-09-05 18:56:24 +00:00
end
end
end