-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add e2e tests for all policy managers (#891)
I recommend reviewing this one commit by commit since it includes lots of minor fixes and improvements to support the e2e tests implementation. There's more context in the individual commit messages too. I've ran the suite on focal, jammy and mantic and got passing runs, however I'll tinker with them some more once everything is set up on GitHub Actions (as part of a follow-up card). Because this PR includes changes to the VM template provisioning script, we will have to refresh the templates once this is merged. Fixes UDENG-1360
- Loading branch information
Showing
18 changed files
with
581 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/sh | ||
touch /etc/adsys-machine-shutdown | ||
touch /etc/created-by-adsys-machine-shutdown-script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/sh | ||
touch /etc/adsys-machine-startup | ||
touch /etc/created-by-adsys-machine-startup-script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/sh | ||
touch ~/adsys-admin-logged-off | ||
touch ~/created-by-adsys-admin-logoff-script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/sh | ||
touch ~/adsys-admin-logged-on | ||
touch ~/created-by-adsys-admin-logon-script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/sh | ||
touch ~/adsys-user-logged-on | ||
touch ~/created-by-adsys-user-logon-script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Package main provides a script that applies and asserts non-Pro policies on | ||
// the provisioned Ubuntu client. | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/ubuntu/adsys/e2e/internal/command" | ||
"github.com/ubuntu/adsys/e2e/internal/inventory" | ||
"github.com/ubuntu/adsys/e2e/internal/remote" | ||
) | ||
|
||
var sshKey string | ||
|
||
func main() { | ||
os.Exit(run()) | ||
} | ||
|
||
func run() int { | ||
cmd := command.New(action, | ||
command.WithValidateFunc(validate), | ||
command.WithRequiredState(inventory.ADProvisioned), | ||
) | ||
cmd.Usage = fmt.Sprintf(`go run ./%s [options] | ||
Apply and assert non-Pro policies on the Ubuntu client. | ||
These policies are configured in the e2e/assets/gpo directory, and described as | ||
part of the ADSys QA Plan document. | ||
https://docs.google.com/document/d/1dIdhqAfNohapcTgWVVeyG7aSDMrGJekeezmoRdd_JSU/ | ||
This script will: | ||
- reboot the client VM to trigger machine policy application | ||
- assert machine GPO rules were applied | ||
- assert users and admins GPO rules were applied | ||
The run is considered successful if the script exits with a zero exit code. | ||
The runner must be connected to the ADSys E2E tests VPN.`, filepath.Base(os.Args[0])) | ||
|
||
return cmd.Execute(context.Background()) | ||
} | ||
|
||
func validate(_ context.Context, cmd *command.Command) (err error) { | ||
sshKey, err = command.ValidateAndExpandPath(cmd.Inventory.SSHKeyPath, command.DefaultSSHKeyPath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func action(ctx context.Context, cmd *command.Command) error { | ||
client, err := remote.NewClient(cmd.Inventory.IP, "root", sshKey) | ||
if err != nil { | ||
return fmt.Errorf("failed to connect to VM: %w", err) | ||
} | ||
|
||
// Reboot machine to apply machine policies | ||
if err := client.Reboot(); err != nil { | ||
return err | ||
} | ||
|
||
// Assert machine policies were applied | ||
if err := client.RequireEqual(ctx, "DCONF_PROFILE=gdm dconf read /org/gnome/desktop/interface/clock-format", "'12h'"); err != nil { | ||
return err | ||
} | ||
if err := client.RequireEqual(ctx, "DCONF_PROFILE=gdm dconf read /org/gnome/desktop/interface/clock-show-weekday", "false"); err != nil { | ||
return err | ||
} | ||
if err := client.RequireEqual(ctx, "DCONF_PROFILE=gdm dconf read /org/gnome/login-screen/banner-message-enable", "true"); err != nil { | ||
return err | ||
} | ||
if err := client.RequireEqual(ctx, "DCONF_PROFILE=gdm dconf read /org/gnome/login-screen/banner-message-text", "'Sample banner text'"); err != nil { | ||
return err | ||
} | ||
|
||
// Pro policies should not be applied yet | ||
if err := client.RequireEqual(ctx, "gsettings get org.gnome.system.proxy.ftp host", "''"); err != nil { | ||
return err | ||
} | ||
|
||
// Assert user GPO policies were applied | ||
client, err = remote.NewClient(cmd.Inventory.IP, fmt.Sprintf("%s-usr@warthogs.biz", cmd.Inventory.Hostname), remote.DomainUserPassword) | ||
if err != nil { | ||
return fmt.Errorf("failed to connect to VM: %w", err) | ||
} | ||
if err := client.RequireEqual(ctx, "dconf read /org/gnome/desktop/background/picture-uri", ""); err != nil { | ||
return err | ||
} | ||
|
||
expectedPictureURIDark := "'file:///usr/share/backgrounds/warty-final-ubuntu.png'" | ||
if cmd.Inventory.Codename == "jammy" { | ||
expectedPictureURIDark = "'file:///usr/share/backgrounds/ubuntu-default-greyscale-wallpaper.png'" | ||
} | ||
if err := client.RequireEqual(ctx, "dconf read /org/gnome/desktop/background/picture-uri-dark", expectedPictureURIDark); err != nil { | ||
return err | ||
} | ||
if err := client.RequireEqual(ctx, "dconf read /org/gnome/shell/favorite-apps", "['firefox.desktop', 'thunderbird.desktop', 'org.gnome.Nautilus.desktop']"); err != nil { | ||
return err | ||
} | ||
|
||
// Assert admin GPO policies were applied | ||
client, err = remote.NewClient(cmd.Inventory.IP, fmt.Sprintf("%s-adm@warthogs.biz", cmd.Inventory.Hostname), remote.DomainUserPassword) | ||
if err != nil { | ||
return fmt.Errorf("failed to connect to VM: %w", err) | ||
} | ||
if err := client.RequireEqual(ctx, "dconf read /org/gnome/shell/favorite-apps", "['rhythmbox.desktop']"); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.