| 
									
										
										
										
											2019-11-09 20:35:50 +01:00
										 |  |  | import ./make-test-python.nix ({ pkgs, lib, ... }: | 
					
						
							| 
									
										
										
										
											2018-12-21 10:36:58 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | let | 
					
						
							|  |  |  |   port = 3142; | 
					
						
							|  |  |  |   username = "alice"; | 
					
						
							|  |  |  |   password = "correcthorsebatterystaple"; | 
					
						
							|  |  |  |   defaultPort = 8080; | 
					
						
							|  |  |  |   defaultUsername = "admin"; | 
					
						
							|  |  |  |   defaultPassword = "password"; | 
					
						
							|  |  |  | in | 
					
						
							|  |  |  | with lib; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   name = "miniflux"; | 
					
						
							| 
									
										
										
										
											2021-01-10 20:08:30 +01:00
										 |  |  |   meta.maintainers = with pkgs.lib.maintainers; [ bricewge ]; | 
					
						
							| 
									
										
										
										
											2018-12-21 10:36:58 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   nodes = { | 
					
						
							|  |  |  |     default = | 
					
						
							|  |  |  |       { ... }: | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         services.miniflux.enable = true; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-28 15:09:31 -03:00
										 |  |  |     withoutSudo = | 
					
						
							|  |  |  |       { ... }: | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         services.miniflux.enable = true; | 
					
						
							|  |  |  |         security.sudo.enable = false; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-21 10:36:58 -08:00
										 |  |  |     customized = | 
					
						
							|  |  |  |       { ... }: | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         services.miniflux = { | 
					
						
							|  |  |  |           enable = true; | 
					
						
							|  |  |  |           config = { | 
					
						
							|  |  |  |             CLEANUP_FREQUENCY = "48"; | 
					
						
							|  |  |  |             LISTEN_ADDR = "localhost:${toString port}"; | 
					
						
							|  |  |  |           }; | 
					
						
							|  |  |  |           adminCredentialsFile = pkgs.writeText "admin-credentials" ''
 | 
					
						
							|  |  |  |             ADMIN_USERNAME=${username} | 
					
						
							|  |  |  |             ADMIN_PASSWORD=${password} | 
					
						
							|  |  |  |           '';
 | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   testScript = ''
 | 
					
						
							| 
									
										
										
										
											2019-11-09 20:35:50 +01:00
										 |  |  |     start_all() | 
					
						
							| 
									
										
										
										
											2018-12-21 10:36:58 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-09 20:35:50 +01:00
										 |  |  |     default.wait_for_unit("miniflux.service") | 
					
						
							|  |  |  |     default.wait_for_open_port(${toString defaultPort}) | 
					
						
							|  |  |  |     default.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep -q OK") | 
					
						
							|  |  |  |     default.succeed( | 
					
						
							|  |  |  |         "curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep -q '\"is_admin\":true'" | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-12-21 10:36:58 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-28 15:09:31 -03:00
										 |  |  |     withoutSudo.wait_for_unit("miniflux.service") | 
					
						
							|  |  |  |     withoutSudo.wait_for_open_port(${toString defaultPort}) | 
					
						
							|  |  |  |     withoutSudo.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep -q OK") | 
					
						
							|  |  |  |     withoutSudo.succeed( | 
					
						
							|  |  |  |         "curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep -q '\"is_admin\":true'" | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-09 20:35:50 +01:00
										 |  |  |     customized.wait_for_unit("miniflux.service") | 
					
						
							|  |  |  |     customized.wait_for_open_port(${toString port}) | 
					
						
							|  |  |  |     customized.succeed("curl --fail 'http://localhost:${toString port}/healthcheck' | grep -q OK") | 
					
						
							|  |  |  |     customized.succeed( | 
					
						
							|  |  |  |         "curl 'http://localhost:${toString port}/v1/me' -u '${username}:${password}' -H Content-Type:application/json | grep -q '\"is_admin\":true'" | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-12-21 10:36:58 -08:00
										 |  |  |   '';
 | 
					
						
							|  |  |  | }) |