ssh.set_known_host
(self)
| 237 | ) |
| 238 | @pytest.mark.slow_test |
| 239 | def test_set_known_host(self): |
| 240 | """ |
| 241 | ssh.set_known_host |
| 242 | """ |
| 243 | # add ssh-rsa item |
| 244 | ret = self.run_function( |
| 245 | "ssh.set_known_host", |
| 246 | ["root", "github.com"], |
| 247 | enc="ssh-rsa", |
| 248 | config=self.known_hosts, |
| 249 | ) |
| 250 | try: |
| 251 | self.assertEqual(ret["status"], "updated") |
| 252 | self.assertEqual(ret["old"], None) |
| 253 | self.assertEqual( |
| 254 | ret["new"][0]["fingerprint"], GITHUB_FINGERPRINTS["ssh-rsa"] |
| 255 | ) |
| 256 | except AssertionError as exc: |
| 257 | raise AssertionError(f"AssertionError: {exc}. Function returned: {ret}") |
| 258 | # check that item does exist |
| 259 | ret = self.run_function( |
| 260 | "ssh.get_known_host_entries", |
| 261 | ["root", "github.com"], |
| 262 | config=self.known_hosts, |
| 263 | )[0] |
| 264 | try: |
| 265 | self.assertEqual(ret["fingerprint"], GITHUB_FINGERPRINTS["ssh-rsa"]) |
| 266 | except AssertionError as exc: |
| 267 | raise AssertionError(f"AssertionError: {exc}. Function returned: {ret}") |
| 268 | # add the same item once again |
| 269 | ret = self.run_function( |
| 270 | "ssh.set_known_host", |
| 271 | ["root", "github.com"], |
| 272 | enc="ssh-rsa", |
| 273 | config=self.known_hosts, |
| 274 | ) |
| 275 | try: |
| 276 | self.assertEqual(ret["status"], "exists") |
| 277 | except AssertionError as exc: |
| 278 | raise AssertionError(f"AssertionError: {exc}. Function returned: {ret}") |
| 279 | # add rest of items |
| 280 | ret = self.run_function( |
| 281 | "ssh.set_known_host", |
| 282 | ["root", "github.com"], |
| 283 | config=self.known_hosts, |
| 284 | ) |
| 285 | try: |
| 286 | self.assertEqual(ret["status"], "updated") |
| 287 | except AssertionError as exc: |
| 288 | raise AssertionError(f"AssertionError: {exc}. Function returned: {ret}") |
| 289 | # check that all items are exist |
| 290 | ret = self.run_function( |
| 291 | "ssh.get_known_host_entries", |
| 292 | ["root", "github.com"], |
| 293 | config=self.known_hosts, |
| 294 | ) |
| 295 | try: |
| 296 | self.assertEqual( |
nothing calls this directly
no test coverage detected