MCPcopy
hub / github.com/saltstack/salt / test_set_known_host

Method test_set_known_host

tests/integration/modules/test_ssh.py:239–300  ·  view source on GitHub ↗

ssh.set_known_host

(self)

Source from the content-addressed store, hash-verified

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(

Callers

nothing calls this directly

Calls 3

setFunction · 0.50
run_functionMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected