# -*- coding: utf-8 -*-
# Copyright (c) 2020, JINGROW
# See license.txt


import unittest

import jingrow

from jcloud.jcloud.pagetype.cluster.test_cluster import create_test_cluster


def create_test_jcloud_settings():
	"""Create test jcloud settings pg"""
	create_test_cluster()
	if not jingrow.db.exists("TLS Certificate", "*.fc.dev"):
		jingrow.get_pg(
			{
				"pagetype": "TLS Certificate",
				"name": "*.fc.dev",
				"domain": "fc.dev",
				"wildcard": True,
				"status": "Active",
				"rsa_key_size": 2048,
			}
		).db_insert()

	jingrow.get_pg(
		{
			"pagetype": "Root Domain",
			"name": "fc.dev",
			"dns_provider": "AWS Route 53",
			"default_cluster": "Default",
			"aws_access_key_id": jingrow.mock("password"),
			"aws_secret_access_key": jingrow.mock("password"),
		}
	).insert(ignore_if_duplicate=True)

	settings = jingrow.get_single("Jcloud Settings")
	settings.domain = "fc.dev"
	settings.bench_configuration = "{}"
	settings.rsa_key_size = 2048
	settings.certbot_directory = ".certbot"
	settings.eff_registration_email = jingrow.mock("email")
	settings.save()
	return settings


class TestJcloudSettings(unittest.TestCase):
	pass
