diff options
author | Patrick Vacek <patrickvacek@gmail.com> | 2018-02-15 12:05:55 +0100 |
---|---|---|
committer | Patrick Vacek <patrickvacek@gmail.com> | 2018-02-20 11:01:34 +0100 |
commit | 9e4918cff53c6154b5bcee2e28deca08280aff75 (patch) | |
tree | e80f99edba5a0aeb4f76865bc07c52c424d0dc98 /lib/oeqa | |
parent | 7bcbb8046672ff66ca7aa0bdf48460d1a11000c3 (diff) | |
download | meta-updater-9e4918cff53c6154b5bcee2e28deca08280aff75.tar.gz |
Add test_cert_provider_local_output.
Improve some organization and logging.
Diffstat (limited to 'lib/oeqa')
-rw-r--r-- | lib/oeqa/selftest/updater.py | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py index 9a3efee..83febb1 100644 --- a/lib/oeqa/selftest/updater.py +++ b/lib/oeqa/selftest/updater.py | |||
@@ -60,6 +60,8 @@ class GeneralTests(oeSelfTest): | |||
60 | self.assertNotEqual(result, -1, 'Feature "systemd" not set at DISTRO_FEATURES') | 60 | self.assertNotEqual(result, -1, 'Feature "systemd" not set at DISTRO_FEATURES') |
61 | 61 | ||
62 | def test_credentials(self): | 62 | def test_credentials(self): |
63 | logger = logging.getLogger("selftest") | ||
64 | logger.info('Running bitbake to build core-image-minimal') | ||
63 | self.write_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') | 65 | self.write_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') |
64 | bitbake('core-image-minimal') | 66 | bitbake('core-image-minimal') |
65 | credentials = get_bb_var('SOTA_PACKED_CREDENTIALS') | 67 | credentials = get_bb_var('SOTA_PACKED_CREDENTIALS') |
@@ -79,22 +81,6 @@ class GeneralTests(oeSelfTest): | |||
79 | result = runCmd('which java', ignore_status=True) | 81 | result = runCmd('which java', ignore_status=True) |
80 | self.assertEqual(result.status, 0, "Java not found.") | 82 | self.assertEqual(result.status, 0, "Java not found.") |
81 | 83 | ||
82 | def test_implicit_writer_help(self): | ||
83 | bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir', 'libdir'], 'aktualizr-native') | ||
84 | l = bb_vars['libdir'] | ||
85 | p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/aktualizr_implicit_writer" | ||
86 | self.assertTrue(os.path.isfile(p), msg = "No aktualizr_implicit_writer found (%s)" % p) | ||
87 | result = runCmd('LD_LIBRARY_PATH=%s %s --help' % (l, p), ignore_status=True) | ||
88 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | ||
89 | |||
90 | def test_cert_provider_help(self): | ||
91 | bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir', 'libdir'], 'aktualizr-native') | ||
92 | l = bb_vars['libdir'] | ||
93 | p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/aktualizr_cert_provider" | ||
94 | self.assertTrue(os.path.isfile(p), msg = "No aktualizr_cert_provider found (%s)" % p) | ||
95 | result = runCmd('LD_LIBRARY_PATH=%s %s --help' % (l, p), ignore_status=True) | ||
96 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | ||
97 | |||
98 | def test_add_package(self): | 84 | def test_add_package(self): |
99 | print('') | 85 | print('') |
100 | deploydir = get_bb_var('DEPLOY_DIR_IMAGE') | 86 | deploydir = get_bb_var('DEPLOY_DIR_IMAGE') |
@@ -126,6 +112,59 @@ class GeneralTests(oeSelfTest): | |||
126 | self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.") | 112 | self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.") |
127 | 113 | ||
128 | 114 | ||
115 | class AktualizrToolsTests(oeSelfTest): | ||
116 | |||
117 | @classmethod | ||
118 | def setUpClass(cls): | ||
119 | logger = logging.getLogger("selftest") | ||
120 | logger.info('Running bitbake to build aktualizr-native tools') | ||
121 | bitbake('aktualizr-native') | ||
122 | |||
123 | def test_implicit_writer_help(self): | ||
124 | bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir', 'libdir'], 'aktualizr-native') | ||
125 | l = bb_vars['libdir'] | ||
126 | p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/aktualizr_implicit_writer" | ||
127 | self.assertTrue(os.path.isfile(p), msg = "No aktualizr_implicit_writer found (%s)" % p) | ||
128 | result = runCmd('LD_LIBRARY_PATH=%s %s --help' % (l, p), ignore_status=True) | ||
129 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | ||
130 | |||
131 | def test_cert_provider_help(self): | ||
132 | bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir', 'libdir'], 'aktualizr-native') | ||
133 | l = bb_vars['libdir'] | ||
134 | p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/aktualizr_cert_provider" | ||
135 | self.assertTrue(os.path.isfile(p), msg = "No aktualizr_cert_provider found (%s)" % p) | ||
136 | result = runCmd('LD_LIBRARY_PATH=%s %s --help' % (l, p), ignore_status=True) | ||
137 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | ||
138 | |||
139 | def test_cert_provider_local_output(self): | ||
140 | logger = logging.getLogger("selftest") | ||
141 | logger.info('Running bitbake to build aktualizr-implicit-prov') | ||
142 | bitbake('aktualizr-implicit-prov') | ||
143 | bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir', 'libdir', | ||
144 | 'SOTA_PACKED_CREDENTIALS', 'T'], 'aktualizr-native') | ||
145 | l = bb_vars['libdir'] | ||
146 | p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/aktualizr_cert_provider" | ||
147 | creds = bb_vars['SOTA_PACKED_CREDENTIALS'] | ||
148 | temp_dir = bb_vars['T'] | ||
149 | bb_vars_prov = get_bb_vars(['STAGING_DIR_NATIVE', 'libdir'], 'aktualizr-implicit-prov') | ||
150 | config = bb_vars_prov['STAGING_DIR_NATIVE'] + bb_vars_prov['libdir'] + '/sota/sota_implicit_prov.toml' | ||
151 | self.assertTrue(os.path.isfile(p), msg = "No aktualizr_cert_provider found (%s)" % p) | ||
152 | command = 'LD_LIBRARY_PATH=' + l + ' ' + p + ' -c ' + creds + ' -r -l ' + temp_dir + ' -g ' + config | ||
153 | # logger.info('Checking output of: ' + command) | ||
154 | result = runCmd(command, ignore_status=True) | ||
155 | self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output) | ||
156 | # Might be nice if these names weren't hardcoded. | ||
157 | cert_path = temp_dir + '/client.pem' | ||
158 | self.assertTrue(os.path.isfile(cert_path), "Client certificate not found at %s." % cert_path) | ||
159 | self.assertTrue(os.path.getsize(cert_path) > 0, "Client certificate at %s is empty." % cert_path) | ||
160 | pkey_path = temp_dir + '/pkey.pem' | ||
161 | self.assertTrue(os.path.isfile(pkey_path), "Private key not found at %s." % pkey_path) | ||
162 | self.assertTrue(os.path.getsize(pkey_path) > 0, "Private key at %s is empty." % pkey_path) | ||
163 | ca_path = temp_dir + '/root.crt' | ||
164 | self.assertTrue(os.path.isfile(ca_path), "Client certificate not found at %s." % ca_path) | ||
165 | self.assertTrue(os.path.getsize(ca_path) > 0, "Client certificate at %s is empty." % ca_path) | ||
166 | |||
167 | |||
129 | class QemuTests(oeSelfTest): | 168 | class QemuTests(oeSelfTest): |
130 | 169 | ||
131 | @classmethod | 170 | @classmethod |