• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2
3# Copyright 2019, The Android Open Source Project
4#
5# Permission is hereby granted, free of charge, to any person
6# obtaining a copy of this software and associated documentation
7# files (the "Software"), to deal in the Software without
8# restriction, including without limitation the rights to use, copy,
9# modify, merge, publish, distribute, sublicense, and/or sell copies
10# of the Software, and to permit persons to whom the Software is
11# furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice shall be
14# included in all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23# SOFTWARE.
24#
25"""Integration tests for the avbtool with an actual AFTL.
26
27The test cases directly interact with a transparency log. However,
28before using this script the following environment variables
29need to be set:
30
31  AFTL_HOST: host:port of the transparency log to test with.
32  AFTL_PUBKEY: Transparency log public key in PEM format.
33  AFTL_APIKEY: If the transparency log requires an API key to submit data,
34      this should be the complete key.
35  AFTL_VBMETA_IMAGE: VBMeta image that should be used for submission to AFTL.
36  AFTL_MANUFACTURER_KEY: Manufacturer signing key used to sign submissions
37      to the transparency log in PEM format.
38"""
39
40import os
41import unittest
42
43import aftltool
44import aftltool_test
45
46
47class AftlIntegrationTest(aftltool_test.AftlTest):
48  """Test suite for integration testing aftltool with an actual AFTL.
49
50  Note: The actual testcases are implemented are implemented as part of the
51  super class. This class only contains the configuration for running the unit
52  tests against as a live log as a means of integration testing.
53  """
54
55  def set_up_environment(self):
56    """Sets up the environment for integration testing with actual AFTL."""
57    self.aftl_host = os.environ.get('AFTL_HOST')
58    self.aftl_pubkey = os.environ.get('AFTL_PUBKEY')
59    self.aftl_apikey = os.environ.get('AFTL_APIKEY')
60    self.vbmeta_image = os.environ.get('AFTL_VBMETA_IMAGE')
61    self.manufacturer_key = os.environ.get('AFTL_MANUFACTURER_KEY')
62
63    if (not self.aftl_host or not self.aftl_pubkey or not self.vbmeta_image
64        or not self.manufacturer_key):
65      self.fail('Environment variables not correctly set up. See description of'
66                ' this test case for details')
67
68  def get_aftl_implementation(self, canned_response):
69    """Retrieves an instance if aftltool.Aftl for integration testing.
70
71    Arguments:
72      canned_response: Since we are using the actual implementation and not a
73      mock this gets ignored.
74
75    Returns:
76      An instance of aftltool.Aftl()
77    """
78    return aftltool.Aftl()
79
80
81if __name__ == '__main__':
82  unittest.main(verbosity=2)
83