| 
									
										
										
										
											2019-11-26 21:57:07 +01:00
										 |  |  | import ./make-test-python.nix ({ pkgs, lib, ... }: | 
					
						
							| 
									
										
										
										
											2018-05-18 18:24:53 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | with lib; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   name = "xss-lock"; | 
					
						
							| 
									
										
										
										
											2021-01-10 20:08:30 +01:00
										 |  |  |   meta.maintainers = with pkgs.lib.maintainers; [ ma27 ]; | 
					
						
							| 
									
										
										
										
											2018-05-18 18:24:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-12 03:22:29 +02:00
										 |  |  |   nodes = { | 
					
						
							|  |  |  |     simple = { | 
					
						
							|  |  |  |       imports = [ ./common/x11.nix ./common/user-account.nix ]; | 
					
						
							|  |  |  |       programs.xss-lock.enable = true; | 
					
						
							| 
									
										
										
										
											2020-01-26 17:41:19 -05:00
										 |  |  |       test-support.displayManager.auto.user = "alice"; | 
					
						
							| 
									
										
										
										
											2019-05-12 03:22:29 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     custom_lockcmd = { pkgs, ... }: { | 
					
						
							|  |  |  |       imports = [ ./common/x11.nix ./common/user-account.nix ]; | 
					
						
							| 
									
										
										
										
											2020-01-26 17:41:19 -05:00
										 |  |  |       test-support.displayManager.auto.user = "alice"; | 
					
						
							| 
									
										
										
										
											2019-05-12 03:22:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       programs.xss-lock = { | 
					
						
							|  |  |  |         enable = true; | 
					
						
							|  |  |  |         extraOptions = [ "-n" "${pkgs.libnotify}/bin/notify-send 'About to sleep!'"]; | 
					
						
							|  |  |  |         lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant"; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2018-05-18 18:24:53 +02:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   testScript = ''
 | 
					
						
							| 
									
										
										
										
											2019-11-26 21:57:07 +01:00
										 |  |  |     def perform_xsslock_test(machine, lockCmd): | 
					
						
							|  |  |  |         machine.start() | 
					
						
							|  |  |  |         machine.wait_for_x() | 
					
						
							|  |  |  |         machine.wait_for_unit("xss-lock.service", "alice") | 
					
						
							|  |  |  |         machine.fail(f"pgrep {lockCmd}") | 
					
						
							|  |  |  |         machine.succeed("su -l alice -c 'xset dpms force standby'") | 
					
						
							|  |  |  |         machine.wait_until_succeeds(f"pgrep {lockCmd}") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     with subtest("simple"): | 
					
						
							|  |  |  |         perform_xsslock_test(simple, "i3lock") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     with subtest("custom_cmd"): | 
					
						
							|  |  |  |         perform_xsslock_test(custom_lockcmd, "xlock") | 
					
						
							| 
									
										
										
										
											2018-05-18 18:24:53 +02:00
										 |  |  |   '';
 | 
					
						
							|  |  |  | }) |