|
825 | 825 | in |
826 | 826 | assertTest "hostconfig-password-requires-username" (!result.success); |
827 | 827 |
|
| 828 | + # https://github.com/kiriwalawren/nixflix/issues/270 |
| 829 | + # settings.auth/settings.server must mirror config.hostConfig so that the |
| 830 | + # environment variables actually reflect what the user configured there. |
| 831 | + hostconfig-drives-settings-auth = |
| 832 | + let |
| 833 | + config = evalConfig [ |
| 834 | + { |
| 835 | + nixflix = { |
| 836 | + enable = true; |
| 837 | + radarr = { |
| 838 | + enable = true; |
| 839 | + config = { |
| 840 | + hostConfig = { |
| 841 | + port = 7878; |
| 842 | + urlBase = "/radarr"; |
| 843 | + authenticationMethod = "external"; |
| 844 | + authenticationRequired = "disabledForLocalAddresses"; |
| 845 | + username = "admin"; |
| 846 | + password._secret = "/run/secrets/radarr-pass"; |
| 847 | + }; |
| 848 | + apiKey._secret = "/run/secrets/radarr-api"; |
| 849 | + rootFolders = [ { path = "/media/movies"; } ]; |
| 850 | + }; |
| 851 | + }; |
| 852 | + }; |
| 853 | + } |
| 854 | + ]; |
| 855 | + radarrCfg = config.config.nixflix.radarr; |
| 856 | + environment = config.config.systemd.services.radarr.environment; |
| 857 | + in |
| 858 | + pkgs.runCommand "unit-test-hostconfig-drives-settings-auth" { } '' |
| 859 | + ${check "settings.auth.method mirrors hostConfig.authenticationMethod" ( |
| 860 | + radarrCfg.settings.auth.method == "External" |
| 861 | + )} |
| 862 | + ${check "settings.auth.required mirrors hostConfig.authenticationRequired" ( |
| 863 | + radarrCfg.settings.auth.required == "DisabledForLocalAddresses" |
| 864 | + )} |
| 865 | + ${check "settings.server.port mirrors hostConfig.port" (radarrCfg.settings.server.port == 7878)} |
| 866 | + ${check "settings.server.urlBase mirrors hostConfig.urlBase" ( |
| 867 | + radarrCfg.settings.server.urlBase == "/radarr" |
| 868 | + )} |
| 869 | + ${check "RADARR__AUTH__METHOD env var reflects hostConfig" ( |
| 870 | + environment.RADARR__AUTH__METHOD == "External" |
| 871 | + )} |
| 872 | + ${check "RADARR__AUTH__REQUIRED env var reflects hostConfig" ( |
| 873 | + environment.RADARR__AUTH__REQUIRED == "DisabledForLocalAddresses" |
| 874 | + )} |
| 875 | + echo 'PASS: hostconfig-drives-settings-auth' > $out |
| 876 | + ''; |
| 877 | + |
| 878 | + # A user should be able to override settings.auth directly (normal priority, |
| 879 | + # no lib.mkForce needed) since the hostConfig-derived value is only mkDefault. |
| 880 | + settings-auth-overrides-hostconfig = |
| 881 | + let |
| 882 | + config = evalConfig [ |
| 883 | + { |
| 884 | + nixflix = { |
| 885 | + enable = true; |
| 886 | + radarr = { |
| 887 | + enable = true; |
| 888 | + config = { |
| 889 | + hostConfig = { |
| 890 | + port = 7878; |
| 891 | + authenticationMethod = "forms"; |
| 892 | + username = "admin"; |
| 893 | + password._secret = "/run/secrets/radarr-pass"; |
| 894 | + }; |
| 895 | + apiKey._secret = "/run/secrets/radarr-api"; |
| 896 | + rootFolders = [ { path = "/media/movies"; } ]; |
| 897 | + }; |
| 898 | + settings.auth.method = "External"; |
| 899 | + }; |
| 900 | + }; |
| 901 | + } |
| 902 | + ]; |
| 903 | + radarrCfg = config.config.nixflix.radarr; |
| 904 | + in |
| 905 | + assertTest "settings-auth-overrides-hostconfig" (radarrCfg.settings.auth.method == "External"); |
828 | 906 | } |
0 commit comments