diff --git a/modules/services/home-assistant.nix b/modules/services/home-assistant.nix index 21a6921..457ba3b 100644 --- a/modules/services/home-assistant.nix +++ b/modules/services/home-assistant.nix @@ -324,8 +324,8 @@ in }; }; - systemd.services.home-assistant.preStart = lib.mkIf cfg.ldap.enable ( - let + systemd.services.home-assistant.preStart = + (let onboarding = pkgs.writeText "onboarding" '' { "version": 4, @@ -333,24 +333,25 @@ in "key": "onboarding", "data": { "done": [ - "user", - "core_config" + ${lib.optionalString cfg.ldap.enable ''"user",''} + "core_config", + "analytics" ] } } ''; storage = "${config.services.home-assistant.configDir}"; file = "${storage}/.storage/onboarding"; - in - '' - if ! -f ${file}; then - mkdir -p ''$(dirname ${file}) && cp ${onboarding} ${file} - fi - '' + shblib.replaceSecrets { - userConfig = cfg.config; - resultPath = "${config.services.home-assistant.configDir}/secrets.yaml"; - generator = shblib.replaceSecretsGeneratorAdapter (lib.generators.toYAML {}); - }); + in '' + if [ ! -f ${file} ]; then + mkdir -p ''$(dirname ${file}) && cp ${onboarding} ${file} + fi + '') + + (lib.optionalString cfg.ldap.enable (shblib.replaceSecrets { + userConfig = cfg.config; + resultPath = "${config.services.home-assistant.configDir}/secrets.yaml"; + generator = shblib.replaceSecretsGeneratorAdapter (lib.generators.toYAML {}); + })); systemd.tmpfiles.rules = [ "f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass" diff --git a/test/services/home-assistant.nix b/test/services/home-assistant.nix index 25a5109..ab31e3b 100644 --- a/test/services/home-assistant.nix +++ b/test/services/home-assistant.nix @@ -14,6 +14,11 @@ let }; basic = { config, ... }: { + imports = [ + testLib.baseModule + ../../modules/services/home-assistant.nix + ]; + test = { subdomain = "ha"; }; @@ -33,6 +38,39 @@ let }; }; + clientLogin = { config, ... }: { + imports = [ + testLib.baseModule + testLib.clientLoginModule + ]; + virtualisation.memorySize = 4096; + + test = { + subdomain = "ha"; + }; + + test.login = { + startUrl = "http://${config.test.fqdn}"; + testLoginWith = [ + { nextPageExpect = [ + "page.get_by_role('button', name=re.compile('Create my smart home')).click()" + + "expect(page.get_by_text('Create user')).to_be_visible()" + "page.get_by_label(re.compile('Name')).fill('Admin')" + "page.get_by_label(re.compile('Username')).fill('admin')" + "page.get_by_label(re.compile('Password')).fill('adminpassword')" + "page.get_by_label(re.compile('Confirm password')).fill('adminpassword')" + "page.get_by_role('button', name=re.compile('Create account')).click()" + + "expect(page.get_by_text('All set')).to_be_visible()" + "page.get_by_role('button', name=re.compile('Finish')).click()" + + "expect(page.get_by_text('Overview')).to_be_visible()" + ]; } + ]; + }; + }; + https = { config, ...}: { shb.home-assistant = { ssl = config.shb.certs.certs.selfsigned.n; @@ -107,10 +145,13 @@ in basic = pkgs.testers.runNixOSTest { name = "homeassistant_basic"; + nodes.client = { + imports = [ + clientLogin + ]; + }; nodes.server = { imports = [ - testLib.baseModule - ../../modules/services/home-assistant.nix basic ]; }; @@ -125,8 +166,6 @@ in nodes.server = { config, ... }: { imports = [ - testLib.baseModule - ../../modules/services/home-assistant.nix basic (testLib.backup config.shb.home-assistant.backup) ]; @@ -142,10 +181,8 @@ in nodes.server = { imports = [ - testLib.baseModule - ../../modules/services/home-assistant.nix - testLib.certs basic + testLib.certs https ]; }; @@ -160,8 +197,6 @@ in nodes.server = { imports = [ - testLib.baseModule - ../../modules/services/home-assistant.nix basic testLib.ldap ldap @@ -179,10 +214,8 @@ in # name = "vaultwarden_sso"; # # nodes.server = lib.mkMerge [ - # testLib.baseModule - # ../../modules/services/home-assistant.nix - # (testLib.certs domain) # basic + # (testLib.certs domain) # https # ldap # (testLib.ldap domain pkgs') @@ -200,8 +233,6 @@ in nodes.server = { imports = [ - testLib.baseModule - ../../modules/services/home-assistant.nix basic voice ];