Skip to content

Commit

Permalink
tests: add focal integration tests when attached to a UA subscription (
Browse files Browse the repository at this point in the history
…canonical#1021)

Adding separate scenarios decorated as @series.focal because behave cannot
distinguish whether --tags was provided, from the scenario's effective_tags from inside the
before_scenario hook.

This way we are going to be able to run only one specific Ubuntu series using behave tags
option --tags=series.focal

Fixes: canonical#1022
  • Loading branch information
patriciadomin authored Apr 15, 2020
1 parent 36ef71d commit d8b1c3a
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 75 deletions.
3 changes: 2 additions & 1 deletion features/attach_invalidtoken.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Feature: Command behaviour when trying to attach a machine to an Ubuntu
Advantage subscription using an invalid token

@series.trusty
Scenario: Attach command in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I run `ua attach INVALID_TOKEN` with sudo
Then I will see the following on stderr:
"""
Expand Down
5 changes: 3 additions & 2 deletions features/attach_validtoken.feature
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@uses.config.contract_token
Feature: Command behaviour when attaching a machine to an Ubuntu Advantage
subscription using a valid token

@uses.config.contract_token
@series.trusty
Scenario: Attach command in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
Then stdout matches regexp:
"""
Expand Down
117 changes: 111 additions & 6 deletions features/attached_commands.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@uses.config.contract_token
Feature: Command behaviour when attached to an UA subscription

@series.trusty
Scenario: Attached refresh in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua refresh` as non-root
Then I will see the following on stderr:
Expand All @@ -15,8 +16,9 @@ Feature: Command behaviour when attached to an UA subscription
Successfully refreshed your subscription
"""

@series.trusty
Scenario: Attached disable of an already disabled service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua disable livepatch` as non-root
Then I will see the following on stderr:
Expand All @@ -30,8 +32,9 @@ Feature: Command behaviour when attached to an UA subscription
See: sudo ua status
"""

@series.trusty
Scenario: Attached disable of an unknown service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua disable foobar` as non-root
Then I will see the following on stderr:
Expand All @@ -45,8 +48,9 @@ Feature: Command behaviour when attached to an UA subscription
For a list of services see: sudo ua status
"""

@series.trusty
Scenario: Attached disable of an already enabled service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua disable esm-infra` as non-root
Then I will see the following on stderr:
Expand All @@ -73,9 +77,9 @@ Feature: Command behaviour when attached to an UA subscription
-32768 https://esm.ubuntu.com/ubuntu/ trusty-infra-security/main amd64 Packages
"""


@series.trusty
Scenario: Attached detach in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua detach` as non-root
Then I will see the following on stderr:
Expand Down Expand Up @@ -105,3 +109,104 @@ Feature: Command behaviour when attached to an UA subscription
"""
This machine is not attached to a UA subscription.
"""

@series.focal
Scenario: Attached refresh in a focal lxd container
Given a `focal` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua refresh` as non-root
Then I will see the following on stderr:
"""
This command must be run as root (try using sudo)
"""
When I run `ua refresh` with sudo
Then I will see the following on stdout:
"""
Successfully refreshed your subscription
"""

@series.focal
Scenario: Attached disable of an already disabled service in a focal lxd container
Given a `focal` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua disable livepatch` as non-root
Then I will see the following on stderr:
"""
This command must be run as root (try using sudo)
"""
When I run `ua disable livepatch` with sudo
Then I will see the following on stdout:
"""
Livepatch is not currently enabled
See: sudo ua status
"""

@series.focal
Scenario: Attached disable of an unknown service in a focal lxd container
Given a `focal` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua disable foobar` as non-root
Then I will see the following on stderr:
"""
This command must be run as root (try using sudo)
"""
When I run `ua disable foobar` with sudo
Then stderr matches regexp:

"""
Cannot disable 'foobar'
For a list of services see: sudo ua status
"""

@series.focal
Scenario: Attached disable of an already enabled service in a focal lxd container
Given a `focal` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua disable esm-infra` as non-root
Then I will see the following on stderr:
"""
This command must be run as root (try using sudo)
"""
When I run `ua disable esm-infra` with sudo
Then I will see the following on stdout:
"""
Updating package lists
"""
When I run `ua status` with sudo
Then stdout matches regexp:
"""
esm-infra +yes +disabled +UA Infra: Extended Security Maintenance
"""

@series.focal
Scenario: Attached detach in a focal lxd container
Given a `focal` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua detach` as non-root
Then I will see the following on stderr:
"""
This command must be run as root (try using sudo)
"""
When I run `ua detach --assume-yes` with sudo
Then I will see the following on stdout:
"""
Detach will disable the following service:
esm-infra
Updating package lists
This machine is now detached
"""
When I run `ua status` as non-root
Then stdout matches regexp:
"""
SERVICE AVAILABLE DESCRIPTION
cc-eal +no +Common Criteria EAL2 Provisioning Packages
esm-apps +yes +UA Apps: Extended Security Maintenance
esm-infra +yes +UA Infra: Extended Security Maintenance
fips +no +NIST-certified FIPS modules
fips-updates +no +Uncertified security updates to FIPS modules
livepatch +yes +Canonical Livepatch service
"""
And stdout matches regexp:
"""
This machine is not attached to a UA subscription.
"""
30 changes: 16 additions & 14 deletions features/attached_enable.feature
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@uses.config.contract_token
Feature: Enable command behaviour when attached to an UA subscription


@series.trusty
Scenario: Attached enable Livepatch service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua enable livepatch` as non-root
Then I will see the following on stderr:
Expand All @@ -17,9 +17,9 @@ Feature: Enable command behaviour when attached to an UA subscription
Cannot install Livepatch on a container
"""


@series.trusty
Scenario: Attached enable Common Criteria service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua enable cc-eal` as non-root
Then I will see the following on stderr:
Expand All @@ -33,9 +33,9 @@ Feature: Enable command behaviour when attached to an UA subscription
CC EAL2 is not available for Ubuntu 14.04 LTS (Trusty Tahr).
"""


@series.trusty
Scenario: Attached enable CIS Audit service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua enable cis-audit` as non-root
Then I will see the following on stderr:
Expand All @@ -50,8 +50,9 @@ Feature: Enable command behaviour when attached to an UA subscription
For more information see: https://ubuntu.com/advantage
"""

@series.trusty
Scenario: Attached enable UA Apps service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua enable esm-apps` as non-root
Then I will see the following on stderr:
Expand All @@ -66,9 +67,9 @@ Feature: Enable command behaviour when attached to an UA subscription
For more information see: https://ubuntu.com/advantage
"""


@series.trusty
Scenario: Attached enable NIST-certified FIPS service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua enable fips` as non-root
Then I will see the following on stderr:
Expand All @@ -82,9 +83,9 @@ Feature: Enable command behaviour when attached to an UA subscription
Cannot install FIPS on a container
"""


@series.trusty
Scenario: Attached enable Uncertified FIPS service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua enable fips-updates` as non-root
Then I will see the following on stderr:
Expand All @@ -98,9 +99,9 @@ Feature: Enable command behaviour when attached to an UA subscription
Cannot install FIPS Updates on a container
"""


@series.trusty
Scenario: Attached enable of an unknown service in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua enable foobar` as non-root
Then I will see the following on stderr:
Expand All @@ -114,8 +115,9 @@ Feature: Enable command behaviour when attached to an UA subscription
For a list of services see: sudo ua status
"""

@series.trusty
Scenario: Attached enable of a known service already enabled (UA Infra) in a trusty lxd container
Given a trusty lxd container with ubuntu-advantage-tools installed
Given a `trusty` lxd container with ubuntu-advantage-tools installed
When I attach contract_token with sudo
And I run `ua enable esm-infra` as non-root
Then I will see the following on stderr:
Expand Down
Loading

0 comments on commit d8b1c3a

Please sign in to comment.