2012 lines
99 KiB
HTML
2012 lines
99 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
|
<meta name="generator" content="pdoc3 0.11.6">
|
|
<title>connpy.tests.test_configfile API documentation</title>
|
|
<meta name="description" content="Tests for connpy.configfile module.">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/13.0.0/sanitize.min.css" integrity="sha512-y1dtMcuvtTMJc1yPgEqF0ZjQbhnc/bFhyvIyVNb9Zk5mIGtqVaAB1Ttl28su8AvFMOY0EwRbAe+HCLqj6W7/KA==" crossorigin>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/13.0.0/typography.min.css" integrity="sha512-Y1DYSb995BAfxobCkKepB1BqJJTPrOp3zPL74AWFugHHmmdcvO+C48WLrUOlhGMc0QG7AE3f7gmvvcrmX2fDoA==" crossorigin>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css" crossorigin>
|
|
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:1.5em;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:2em 0 .50em 0}h3{font-size:1.4em;margin:1.6em 0 .7em 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .2s ease-in-out}a:visited{color:#503}a:hover{color:#b62}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900;font-weight:bold}pre code{font-size:.8em;line-height:1.4em;padding:1em;display:block}code{background:#f3f3f3;font-family:"DejaVu Sans Mono",monospace;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source > summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible;min-width:max-content}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em 1em;margin:1em 0}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
|
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul ul{padding-left:1em}.toc > ul > li{margin-top:.5em}}</style>
|
|
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
|
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin></script>
|
|
<script>window.addEventListener('DOMContentLoaded', () => {
|
|
hljs.configure({languages: ['bash', 'css', 'diff', 'graphql', 'ini', 'javascript', 'json', 'plaintext', 'python', 'python-repl', 'rust', 'shell', 'sql', 'typescript', 'xml', 'yaml']});
|
|
hljs.highlightAll();
|
|
/* Collapse source docstrings */
|
|
setTimeout(() => {
|
|
[...document.querySelectorAll('.hljs.language-python > .hljs-string')]
|
|
.filter(el => el.innerHTML.length > 200 && ['"""', "'''"].includes(el.innerHTML.substring(0, 3)))
|
|
.forEach(el => {
|
|
let d = document.createElement('details');
|
|
d.classList.add('hljs-string');
|
|
d.innerHTML = '<summary>"""</summary>' + el.innerHTML.substring(3);
|
|
el.replaceWith(d);
|
|
});
|
|
}, 100);
|
|
})</script>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<article id="content">
|
|
<header>
|
|
<h1 class="title">Module <code>connpy.tests.test_configfile</code></h1>
|
|
</header>
|
|
<section id="section-intro">
|
|
<p>Tests for connpy.configfile module.</p>
|
|
</section>
|
|
<section>
|
|
</section>
|
|
<section>
|
|
</section>
|
|
<section>
|
|
</section>
|
|
<section>
|
|
<h2 class="section-title" id="header-classes">Classes</h2>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestAtomicSave"><code class="flex name class">
|
|
<span>class <span class="ident">TestAtomicSave</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestAtomicSave:
|
|
def test_save_creates_no_leftover_tmp(self, config):
|
|
"""After successful save, no .tmp file remains."""
|
|
config._connections_add(
|
|
id="test123", host="1.2.3.4", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
result = config._saveconfig(config.file)
|
|
assert result == 0
|
|
assert not os.path.exists(config.file + '.tmp')
|
|
|
|
def test_save_preserves_original_on_error(self, config):
|
|
"""If save fails, original config file is not corrupted."""
|
|
import unittest.mock as mock
|
|
|
|
config._connections_add(
|
|
id="original_node", host="10.0.0.1", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
config._saveconfig(config.file)
|
|
|
|
# Now add another node and make yaml.dump fail
|
|
config._connections_add(
|
|
id="new_node", host="10.0.0.2", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
|
|
with mock.patch('connpy.configfile.yaml.dump', side_effect=IOError("disk full")):
|
|
result = config._saveconfig(config.file)
|
|
assert result == 1
|
|
|
|
# Original file should still be valid with original_node
|
|
from connpy.configfile import configfile
|
|
reloaded = configfile(conf=config.file, key=config.key)
|
|
assert "original_node" in reloaded.connections</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestAtomicSave.test_save_creates_no_leftover_tmp"><code class="name flex">
|
|
<span>def <span class="ident">test_save_creates_no_leftover_tmp</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_save_creates_no_leftover_tmp(self, config):
|
|
"""After successful save, no .tmp file remains."""
|
|
config._connections_add(
|
|
id="test123", host="1.2.3.4", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
result = config._saveconfig(config.file)
|
|
assert result == 0
|
|
assert not os.path.exists(config.file + '.tmp')</code></pre>
|
|
</details>
|
|
<div class="desc"><p>After successful save, no .tmp file remains.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestAtomicSave.test_save_preserves_original_on_error"><code class="name flex">
|
|
<span>def <span class="ident">test_save_preserves_original_on_error</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_save_preserves_original_on_error(self, config):
|
|
"""If save fails, original config file is not corrupted."""
|
|
import unittest.mock as mock
|
|
|
|
config._connections_add(
|
|
id="original_node", host="10.0.0.1", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
config._saveconfig(config.file)
|
|
|
|
# Now add another node and make yaml.dump fail
|
|
config._connections_add(
|
|
id="new_node", host="10.0.0.2", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
|
|
with mock.patch('connpy.configfile.yaml.dump', side_effect=IOError("disk full")):
|
|
result = config._saveconfig(config.file)
|
|
assert result == 1
|
|
|
|
# Original file should still be valid with original_node
|
|
from connpy.configfile import configfile
|
|
reloaded = configfile(conf=config.file, key=config.key)
|
|
assert "original_node" in reloaded.connections</code></pre>
|
|
</details>
|
|
<div class="desc"><p>If save fails, original config file is not corrupted.</p></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes"><code class="flex name class">
|
|
<span>class <span class="ident">TestCRUDNodes</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestCRUDNodes:
|
|
def test_add_node_root(self, config):
|
|
config._connections_add(
|
|
id="router1", host="10.0.0.1", protocol="ssh",
|
|
port="22", user="admin", password="pass", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
assert "router1" in config.connections
|
|
assert config.connections["router1"]["host"] == "10.0.0.1"
|
|
|
|
def test_add_node_folder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._connections_add(
|
|
id="server1", folder="office", host="10.0.1.1",
|
|
protocol="ssh", port="", user="root", password="pass",
|
|
options="", logs="", tags="", jumphost=""
|
|
)
|
|
assert "server1" in config.connections["office"]
|
|
|
|
def test_add_node_subfolder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._folder_add(folder="office", subfolder="dc")
|
|
config._connections_add(
|
|
id="db1", folder="office", subfolder="dc", host="10.0.2.1",
|
|
protocol="ssh", port="", user="dbadmin", password="pass",
|
|
options="", logs="", tags="", jumphost=""
|
|
)
|
|
assert "db1" in config.connections["office"]["dc"]
|
|
|
|
def test_del_node_root(self, config):
|
|
config._connections_add(
|
|
id="router1", host="10.0.0.1", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
config._connections_del(id="router1")
|
|
assert "router1" not in config.connections
|
|
|
|
def test_del_node_folder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._connections_add(
|
|
id="server1", folder="office", host="10.0.1.1",
|
|
protocol="ssh", port="", user="", password="",
|
|
options="", logs="", tags="", jumphost=""
|
|
)
|
|
config._connections_del(id="server1", folder="office")
|
|
assert "server1" not in config.connections["office"]
|
|
|
|
def test_add_folder(self, config):
|
|
config._folder_add(folder="office")
|
|
assert "office" in config.connections
|
|
assert config.connections["office"]["type"] == "folder"
|
|
|
|
def test_add_subfolder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._folder_add(folder="office", subfolder="dc")
|
|
assert "dc" in config.connections["office"]
|
|
assert config.connections["office"]["dc"]["type"] == "subfolder"
|
|
|
|
def test_del_folder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._folder_del(folder="office")
|
|
assert "office" not in config.connections
|
|
|
|
def test_del_subfolder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._folder_add(folder="office", subfolder="dc")
|
|
config._folder_del(folder="office", subfolder="dc")
|
|
assert "dc" not in config.connections["office"]</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes.test_add_folder"><code class="name flex">
|
|
<span>def <span class="ident">test_add_folder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_add_folder(self, config):
|
|
config._folder_add(folder="office")
|
|
assert "office" in config.connections
|
|
assert config.connections["office"]["type"] == "folder"</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes.test_add_node_folder"><code class="name flex">
|
|
<span>def <span class="ident">test_add_node_folder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_add_node_folder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._connections_add(
|
|
id="server1", folder="office", host="10.0.1.1",
|
|
protocol="ssh", port="", user="root", password="pass",
|
|
options="", logs="", tags="", jumphost=""
|
|
)
|
|
assert "server1" in config.connections["office"]</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes.test_add_node_root"><code class="name flex">
|
|
<span>def <span class="ident">test_add_node_root</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_add_node_root(self, config):
|
|
config._connections_add(
|
|
id="router1", host="10.0.0.1", protocol="ssh",
|
|
port="22", user="admin", password="pass", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
assert "router1" in config.connections
|
|
assert config.connections["router1"]["host"] == "10.0.0.1"</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes.test_add_node_subfolder"><code class="name flex">
|
|
<span>def <span class="ident">test_add_node_subfolder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_add_node_subfolder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._folder_add(folder="office", subfolder="dc")
|
|
config._connections_add(
|
|
id="db1", folder="office", subfolder="dc", host="10.0.2.1",
|
|
protocol="ssh", port="", user="dbadmin", password="pass",
|
|
options="", logs="", tags="", jumphost=""
|
|
)
|
|
assert "db1" in config.connections["office"]["dc"]</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes.test_add_subfolder"><code class="name flex">
|
|
<span>def <span class="ident">test_add_subfolder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_add_subfolder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._folder_add(folder="office", subfolder="dc")
|
|
assert "dc" in config.connections["office"]
|
|
assert config.connections["office"]["dc"]["type"] == "subfolder"</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes.test_del_folder"><code class="name flex">
|
|
<span>def <span class="ident">test_del_folder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_del_folder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._folder_del(folder="office")
|
|
assert "office" not in config.connections</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes.test_del_node_folder"><code class="name flex">
|
|
<span>def <span class="ident">test_del_node_folder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_del_node_folder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._connections_add(
|
|
id="server1", folder="office", host="10.0.1.1",
|
|
protocol="ssh", port="", user="", password="",
|
|
options="", logs="", tags="", jumphost=""
|
|
)
|
|
config._connections_del(id="server1", folder="office")
|
|
assert "server1" not in config.connections["office"]</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes.test_del_node_root"><code class="name flex">
|
|
<span>def <span class="ident">test_del_node_root</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_del_node_root(self, config):
|
|
config._connections_add(
|
|
id="router1", host="10.0.0.1", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
config._connections_del(id="router1")
|
|
assert "router1" not in config.connections</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDNodes.test_del_subfolder"><code class="name flex">
|
|
<span>def <span class="ident">test_del_subfolder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_del_subfolder(self, config):
|
|
config._folder_add(folder="office")
|
|
config._folder_add(folder="office", subfolder="dc")
|
|
config._folder_del(folder="office", subfolder="dc")
|
|
assert "dc" not in config.connections["office"]</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDProfiles"><code class="flex name class">
|
|
<span>class <span class="ident">TestCRUDProfiles</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestCRUDProfiles:
|
|
def test_add_profile(self, config):
|
|
config._profiles_add(
|
|
id="myprofile", host="", protocol="telnet",
|
|
port="23", user="user1", password="pass1",
|
|
options="", logs="", tags="", jumphost=""
|
|
)
|
|
assert "myprofile" in config.profiles
|
|
assert config.profiles["myprofile"]["protocol"] == "telnet"
|
|
|
|
def test_del_profile(self, config):
|
|
config._profiles_add(
|
|
id="temp", host="", protocol="ssh", port="",
|
|
user="", password="", options="", logs="", tags="", jumphost=""
|
|
)
|
|
config._profiles_del(id="temp")
|
|
assert "temp" not in config.profiles
|
|
|
|
def test_default_profile_exists(self, config):
|
|
assert "default" in config.profiles</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDProfiles.test_add_profile"><code class="name flex">
|
|
<span>def <span class="ident">test_add_profile</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_add_profile(self, config):
|
|
config._profiles_add(
|
|
id="myprofile", host="", protocol="telnet",
|
|
port="23", user="user1", password="pass1",
|
|
options="", logs="", tags="", jumphost=""
|
|
)
|
|
assert "myprofile" in config.profiles
|
|
assert config.profiles["myprofile"]["protocol"] == "telnet"</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDProfiles.test_default_profile_exists"><code class="name flex">
|
|
<span>def <span class="ident">test_default_profile_exists</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_default_profile_exists(self, config):
|
|
assert "default" in config.profiles</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCRUDProfiles.test_del_profile"><code class="name flex">
|
|
<span>def <span class="ident">test_del_profile</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_del_profile(self, config):
|
|
config._profiles_add(
|
|
id="temp", host="", protocol="ssh", port="",
|
|
user="", password="", options="", logs="", tags="", jumphost=""
|
|
)
|
|
config._profiles_del(id="temp")
|
|
assert "temp" not in config.profiles</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestConfigfileInit"><code class="flex name class">
|
|
<span>class <span class="ident">TestConfigfileInit</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestConfigfileInit:
|
|
def test_creates_default_config(self, tmp_config_dir):
|
|
"""Creates config.yaml with defaults when it doesn't exist."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
config_file.unlink(missing_ok=True) # Remove existing
|
|
key_file = tmp_config_dir / ".osk"
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(key_file))
|
|
|
|
assert config_file.exists()
|
|
assert conf.config["case"] == False
|
|
assert conf.config["idletime"] == 30
|
|
assert "default" in conf.profiles
|
|
|
|
def test_creates_rsa_key(self, tmp_config_dir):
|
|
"""Generates RSA key when it doesn't exist."""
|
|
key_file = tmp_config_dir / ".osk"
|
|
key_file.unlink() # Remove existing
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(tmp_config_dir / "config.yaml"), key=str(key_file))
|
|
|
|
assert key_file.exists()
|
|
assert conf.privatekey is not None
|
|
assert conf.publickey is not None
|
|
|
|
def test_loads_existing_config(self, config):
|
|
"""Loads correctly from existing config."""
|
|
assert config.config is not None
|
|
assert config.connections is not None
|
|
assert config.profiles is not None
|
|
|
|
def test_config_file_permissions(self, tmp_config_dir):
|
|
"""Config is created with 0o600 permissions."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
config_file.unlink(missing_ok=True)
|
|
|
|
from connpy.configfile import configfile
|
|
configfile(conf=str(config_file), key=str(tmp_config_dir / ".osk"))
|
|
|
|
stat = os.stat(str(config_file))
|
|
assert oct(stat.st_mode & 0o777) == oct(0o600)
|
|
|
|
def test_custom_paths(self, tmp_path):
|
|
"""Accepts custom paths for conf and key."""
|
|
config_dir = tmp_path / "custom"
|
|
config_dir.mkdir()
|
|
(config_dir / "plugins").mkdir()
|
|
|
|
# Write .folder for the config dir
|
|
dot_folder = tmp_path / ".config" / "conn"
|
|
dot_folder.mkdir(parents=True, exist_ok=True)
|
|
(dot_folder / ".folder").write_text(str(config_dir))
|
|
(dot_folder / "plugins").mkdir(exist_ok=True)
|
|
|
|
conf_path = str(config_dir / "my_config.yaml")
|
|
key_path = str(config_dir / "my_key")
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=conf_path, key=key_path)
|
|
|
|
assert conf.file == conf_path
|
|
assert conf.key == key_path</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestConfigfileInit.test_config_file_permissions"><code class="name flex">
|
|
<span>def <span class="ident">test_config_file_permissions</span></span>(<span>self, tmp_config_dir)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_config_file_permissions(self, tmp_config_dir):
|
|
"""Config is created with 0o600 permissions."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
config_file.unlink(missing_ok=True)
|
|
|
|
from connpy.configfile import configfile
|
|
configfile(conf=str(config_file), key=str(tmp_config_dir / ".osk"))
|
|
|
|
stat = os.stat(str(config_file))
|
|
assert oct(stat.st_mode & 0o777) == oct(0o600)</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Config is created with 0o600 permissions.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestConfigfileInit.test_creates_default_config"><code class="name flex">
|
|
<span>def <span class="ident">test_creates_default_config</span></span>(<span>self, tmp_config_dir)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_creates_default_config(self, tmp_config_dir):
|
|
"""Creates config.yaml with defaults when it doesn't exist."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
config_file.unlink(missing_ok=True) # Remove existing
|
|
key_file = tmp_config_dir / ".osk"
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(key_file))
|
|
|
|
assert config_file.exists()
|
|
assert conf.config["case"] == False
|
|
assert conf.config["idletime"] == 30
|
|
assert "default" in conf.profiles</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Creates config.yaml with defaults when it doesn't exist.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestConfigfileInit.test_creates_rsa_key"><code class="name flex">
|
|
<span>def <span class="ident">test_creates_rsa_key</span></span>(<span>self, tmp_config_dir)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_creates_rsa_key(self, tmp_config_dir):
|
|
"""Generates RSA key when it doesn't exist."""
|
|
key_file = tmp_config_dir / ".osk"
|
|
key_file.unlink() # Remove existing
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(tmp_config_dir / "config.yaml"), key=str(key_file))
|
|
|
|
assert key_file.exists()
|
|
assert conf.privatekey is not None
|
|
assert conf.publickey is not None</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Generates RSA key when it doesn't exist.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestConfigfileInit.test_custom_paths"><code class="name flex">
|
|
<span>def <span class="ident">test_custom_paths</span></span>(<span>self, tmp_path)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_custom_paths(self, tmp_path):
|
|
"""Accepts custom paths for conf and key."""
|
|
config_dir = tmp_path / "custom"
|
|
config_dir.mkdir()
|
|
(config_dir / "plugins").mkdir()
|
|
|
|
# Write .folder for the config dir
|
|
dot_folder = tmp_path / ".config" / "conn"
|
|
dot_folder.mkdir(parents=True, exist_ok=True)
|
|
(dot_folder / ".folder").write_text(str(config_dir))
|
|
(dot_folder / "plugins").mkdir(exist_ok=True)
|
|
|
|
conf_path = str(config_dir / "my_config.yaml")
|
|
key_path = str(config_dir / "my_key")
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=conf_path, key=key_path)
|
|
|
|
assert conf.file == conf_path
|
|
assert conf.key == key_path</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Accepts custom paths for conf and key.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestConfigfileInit.test_loads_existing_config"><code class="name flex">
|
|
<span>def <span class="ident">test_loads_existing_config</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_loads_existing_config(self, config):
|
|
"""Loads correctly from existing config."""
|
|
assert config.config is not None
|
|
assert config.connections is not None
|
|
assert config.profiles is not None</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Loads correctly from existing config.</p></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCorruptionRecovery"><code class="flex name class">
|
|
<span>class <span class="ident">TestCorruptionRecovery</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestCorruptionRecovery:
|
|
def test_corrupt_yaml_recovers_from_cache(self, tmp_config_dir):
|
|
"""If YAML is corrupt but cache is valid, recovers from cache."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
key_file = tmp_config_dir / ".osk"
|
|
|
|
# Write valid config with router1
|
|
valid_data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {"router1": {"host": "10.0.0.1", "type": "connection", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}},
|
|
"profiles": {"default": {"host": "", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}}
|
|
}
|
|
config_file.write_text(yaml.dump(valid_data, default_flow_style=False, sort_keys=False))
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(key_file))
|
|
# Save to populate cache at the real self.cachefile path
|
|
conf._saveconfig(conf.file)
|
|
cachefile_path = conf.cachefile
|
|
assert os.path.exists(cachefile_path)
|
|
|
|
# Now corrupt the YAML
|
|
config_file.write_text("")
|
|
import time; time.sleep(0.05) # Ensure YAML is newer than cache
|
|
|
|
# Reload - should recover from cache
|
|
conf2 = configfile(conf=str(config_file), key=str(key_file))
|
|
assert "router1" in conf2.connections
|
|
assert conf2.connections["router1"]["host"] == "10.0.0.1"
|
|
|
|
def test_corrupt_cache_uses_yaml(self, tmp_config_dir):
|
|
"""If cache is corrupt but YAML is valid, uses YAML."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
key_file = tmp_config_dir / ".osk"
|
|
|
|
valid_data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {},
|
|
"profiles": {"default": {"host": "", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}}
|
|
}
|
|
config_file.write_text(yaml.dump(valid_data, default_flow_style=False, sort_keys=False))
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(key_file))
|
|
cachefile_path = conf.cachefile
|
|
|
|
# Now corrupt the cache (valid JSON but invalid config structure)
|
|
from pathlib import Path
|
|
Path(cachefile_path).write_text(json.dumps({"garbage": True}))
|
|
# Make cache newer than YAML to force cache path
|
|
import time; time.sleep(0.05)
|
|
os.utime(cachefile_path, None)
|
|
|
|
conf2 = configfile(conf=str(config_file), key=str(key_file))
|
|
assert conf2.config["case"] == False
|
|
assert "default" in conf2.profiles
|
|
|
|
def test_both_corrupt_creates_default(self, tmp_config_dir):
|
|
"""If both YAML and cache are corrupt, creates fresh config."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
key_file = tmp_config_dir / ".osk"
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(key_file))
|
|
cachefile_path = conf.cachefile
|
|
|
|
# Corrupt YAML
|
|
config_file.write_text("")
|
|
# Corrupt cache
|
|
from pathlib import Path
|
|
Path(cachefile_path).write_text(json.dumps({"garbage": True}))
|
|
import time; time.sleep(0.05)
|
|
os.utime(str(config_file), None)
|
|
|
|
conf2 = configfile(conf=str(config_file), key=str(key_file))
|
|
|
|
# Should get defaults, not crash
|
|
assert conf2.config is not None
|
|
assert "default" in conf2.profiles
|
|
assert isinstance(conf2.connections, dict)</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestCorruptionRecovery.test_both_corrupt_creates_default"><code class="name flex">
|
|
<span>def <span class="ident">test_both_corrupt_creates_default</span></span>(<span>self, tmp_config_dir)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_both_corrupt_creates_default(self, tmp_config_dir):
|
|
"""If both YAML and cache are corrupt, creates fresh config."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
key_file = tmp_config_dir / ".osk"
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(key_file))
|
|
cachefile_path = conf.cachefile
|
|
|
|
# Corrupt YAML
|
|
config_file.write_text("")
|
|
# Corrupt cache
|
|
from pathlib import Path
|
|
Path(cachefile_path).write_text(json.dumps({"garbage": True}))
|
|
import time; time.sleep(0.05)
|
|
os.utime(str(config_file), None)
|
|
|
|
conf2 = configfile(conf=str(config_file), key=str(key_file))
|
|
|
|
# Should get defaults, not crash
|
|
assert conf2.config is not None
|
|
assert "default" in conf2.profiles
|
|
assert isinstance(conf2.connections, dict)</code></pre>
|
|
</details>
|
|
<div class="desc"><p>If both YAML and cache are corrupt, creates fresh config.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCorruptionRecovery.test_corrupt_cache_uses_yaml"><code class="name flex">
|
|
<span>def <span class="ident">test_corrupt_cache_uses_yaml</span></span>(<span>self, tmp_config_dir)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_corrupt_cache_uses_yaml(self, tmp_config_dir):
|
|
"""If cache is corrupt but YAML is valid, uses YAML."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
key_file = tmp_config_dir / ".osk"
|
|
|
|
valid_data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {},
|
|
"profiles": {"default": {"host": "", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}}
|
|
}
|
|
config_file.write_text(yaml.dump(valid_data, default_flow_style=False, sort_keys=False))
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(key_file))
|
|
cachefile_path = conf.cachefile
|
|
|
|
# Now corrupt the cache (valid JSON but invalid config structure)
|
|
from pathlib import Path
|
|
Path(cachefile_path).write_text(json.dumps({"garbage": True}))
|
|
# Make cache newer than YAML to force cache path
|
|
import time; time.sleep(0.05)
|
|
os.utime(cachefile_path, None)
|
|
|
|
conf2 = configfile(conf=str(config_file), key=str(key_file))
|
|
assert conf2.config["case"] == False
|
|
assert "default" in conf2.profiles</code></pre>
|
|
</details>
|
|
<div class="desc"><p>If cache is corrupt but YAML is valid, uses YAML.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestCorruptionRecovery.test_corrupt_yaml_recovers_from_cache"><code class="name flex">
|
|
<span>def <span class="ident">test_corrupt_yaml_recovers_from_cache</span></span>(<span>self, tmp_config_dir)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_corrupt_yaml_recovers_from_cache(self, tmp_config_dir):
|
|
"""If YAML is corrupt but cache is valid, recovers from cache."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
key_file = tmp_config_dir / ".osk"
|
|
|
|
# Write valid config with router1
|
|
valid_data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {"router1": {"host": "10.0.0.1", "type": "connection", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}},
|
|
"profiles": {"default": {"host": "", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}}
|
|
}
|
|
config_file.write_text(yaml.dump(valid_data, default_flow_style=False, sort_keys=False))
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(key_file))
|
|
# Save to populate cache at the real self.cachefile path
|
|
conf._saveconfig(conf.file)
|
|
cachefile_path = conf.cachefile
|
|
assert os.path.exists(cachefile_path)
|
|
|
|
# Now corrupt the YAML
|
|
config_file.write_text("")
|
|
import time; time.sleep(0.05) # Ensure YAML is newer than cache
|
|
|
|
# Reload - should recover from cache
|
|
conf2 = configfile(conf=str(config_file), key=str(key_file))
|
|
assert "router1" in conf2.connections
|
|
assert conf2.connections["router1"]["host"] == "10.0.0.1"</code></pre>
|
|
</details>
|
|
<div class="desc"><p>If YAML is corrupt but cache is valid, recovers from cache.</p></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestEncryption"><code class="flex name class">
|
|
<span>class <span class="ident">TestEncryption</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestEncryption:
|
|
def test_encrypt_password(self, config):
|
|
"""Encrypts and produces b'...' format."""
|
|
encrypted = config.encrypt("mysecret")
|
|
assert encrypted.startswith("b'") or encrypted.startswith('b"')
|
|
|
|
def test_encrypt_decrypt_roundtrip(self, config):
|
|
"""Encrypt then decrypt returns original."""
|
|
from Crypto.PublicKey import RSA
|
|
from Crypto.Cipher import PKCS1_OAEP
|
|
import ast
|
|
|
|
original = "super_secret_password"
|
|
encrypted = config.encrypt(original)
|
|
|
|
# Decrypt
|
|
with open(config.key) as f:
|
|
key = RSA.import_key(f.read())
|
|
decryptor = PKCS1_OAEP.new(key)
|
|
decrypted = decryptor.decrypt(ast.literal_eval(encrypted)).decode("utf-8")
|
|
assert decrypted == original</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestEncryption.test_encrypt_decrypt_roundtrip"><code class="name flex">
|
|
<span>def <span class="ident">test_encrypt_decrypt_roundtrip</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_encrypt_decrypt_roundtrip(self, config):
|
|
"""Encrypt then decrypt returns original."""
|
|
from Crypto.PublicKey import RSA
|
|
from Crypto.Cipher import PKCS1_OAEP
|
|
import ast
|
|
|
|
original = "super_secret_password"
|
|
encrypted = config.encrypt(original)
|
|
|
|
# Decrypt
|
|
with open(config.key) as f:
|
|
key = RSA.import_key(f.read())
|
|
decryptor = PKCS1_OAEP.new(key)
|
|
decrypted = decryptor.decrypt(ast.literal_eval(encrypted)).decode("utf-8")
|
|
assert decrypted == original</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Encrypt then decrypt returns original.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestEncryption.test_encrypt_password"><code class="name flex">
|
|
<span>def <span class="ident">test_encrypt_password</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_encrypt_password(self, config):
|
|
"""Encrypts and produces b'...' format."""
|
|
encrypted = config.encrypt("mysecret")
|
|
assert encrypted.startswith("b'") or encrypted.startswith('b"')</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Encrypts and produces b'…' format.</p></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestExplodeUnique"><code class="flex name class">
|
|
<span>class <span class="ident">TestExplodeUnique</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestExplodeUnique:
|
|
def test_simple_node(self, config):
|
|
result = config._explode_unique("router1")
|
|
assert result == {"id": "router1"}
|
|
|
|
def test_node_with_folder(self, config):
|
|
result = config._explode_unique("r1@office")
|
|
assert result == {"id": "r1", "folder": "office"}
|
|
|
|
def test_node_with_subfolder(self, config):
|
|
result = config._explode_unique("r1@dc@office")
|
|
assert result == {"id": "r1", "folder": "office", "subfolder": "dc"}
|
|
|
|
def test_folder_only(self, config):
|
|
result = config._explode_unique("@office")
|
|
assert result == {"folder": "office"}
|
|
|
|
def test_subfolder_only(self, config):
|
|
result = config._explode_unique("@dc@office")
|
|
assert result == {"folder": "office", "subfolder": "dc"}
|
|
|
|
def test_too_deep(self, config):
|
|
result = config._explode_unique("a@b@c@d")
|
|
assert result == False
|
|
|
|
def test_empty_folder(self, config):
|
|
result = config._explode_unique("a@")
|
|
assert result == False
|
|
|
|
def test_empty_subfolder(self, config):
|
|
result = config._explode_unique("a@@office")
|
|
assert result == False</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestExplodeUnique.test_empty_folder"><code class="name flex">
|
|
<span>def <span class="ident">test_empty_folder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_empty_folder(self, config):
|
|
result = config._explode_unique("a@")
|
|
assert result == False</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestExplodeUnique.test_empty_subfolder"><code class="name flex">
|
|
<span>def <span class="ident">test_empty_subfolder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_empty_subfolder(self, config):
|
|
result = config._explode_unique("a@@office")
|
|
assert result == False</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestExplodeUnique.test_folder_only"><code class="name flex">
|
|
<span>def <span class="ident">test_folder_only</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_folder_only(self, config):
|
|
result = config._explode_unique("@office")
|
|
assert result == {"folder": "office"}</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestExplodeUnique.test_node_with_folder"><code class="name flex">
|
|
<span>def <span class="ident">test_node_with_folder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_node_with_folder(self, config):
|
|
result = config._explode_unique("r1@office")
|
|
assert result == {"id": "r1", "folder": "office"}</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestExplodeUnique.test_node_with_subfolder"><code class="name flex">
|
|
<span>def <span class="ident">test_node_with_subfolder</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_node_with_subfolder(self, config):
|
|
result = config._explode_unique("r1@dc@office")
|
|
assert result == {"id": "r1", "folder": "office", "subfolder": "dc"}</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestExplodeUnique.test_simple_node"><code class="name flex">
|
|
<span>def <span class="ident">test_simple_node</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_simple_node(self, config):
|
|
result = config._explode_unique("router1")
|
|
assert result == {"id": "router1"}</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestExplodeUnique.test_subfolder_only"><code class="name flex">
|
|
<span>def <span class="ident">test_subfolder_only</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_subfolder_only(self, config):
|
|
result = config._explode_unique("@dc@office")
|
|
assert result == {"folder": "office", "subfolder": "dc"}</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestExplodeUnique.test_too_deep"><code class="name flex">
|
|
<span>def <span class="ident">test_too_deep</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_too_deep(self, config):
|
|
result = config._explode_unique("a@b@c@d")
|
|
assert result == False</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll"><code class="flex name class">
|
|
<span>class <span class="ident">TestGetAll</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestGetAll:
|
|
def test_getallnodes_no_filter(self, populated_config):
|
|
nodes = populated_config._getallnodes()
|
|
assert "router1" in nodes
|
|
assert "server1@office" in nodes
|
|
assert "db1@datacenter@office" in nodes
|
|
|
|
def test_getallnodes_string_filter(self, populated_config):
|
|
nodes = populated_config._getallnodes("router.*")
|
|
assert "router1" in nodes
|
|
assert "server1@office" not in nodes
|
|
|
|
def test_getallnodes_list_filter(self, populated_config):
|
|
nodes = populated_config._getallnodes(["router.*", "db.*"])
|
|
assert "router1" in nodes
|
|
assert "db1@datacenter@office" in nodes
|
|
assert "server1@office" not in nodes
|
|
|
|
def test_getallnodes_filter_invalid_type(self, populated_config):
|
|
with pytest.raises(SystemExit) as exc:
|
|
populated_config._getallnodes(123)
|
|
assert exc.value.code == 1
|
|
|
|
def test_getallfolders(self, populated_config):
|
|
folders = populated_config._getallfolders()
|
|
assert "@office" in folders
|
|
assert "@datacenter@office" in folders
|
|
|
|
def test_getallnodesfull(self, populated_config):
|
|
nodes = populated_config._getallnodesfull()
|
|
assert "router1" in nodes
|
|
assert nodes["router1"]["host"] == "10.0.0.1"
|
|
|
|
def test_getallnodesfull_with_filter(self, populated_config):
|
|
nodes = populated_config._getallnodesfull("router.*")
|
|
assert "router1" in nodes
|
|
assert "server1@office" not in nodes
|
|
|
|
def test_profileused(self, tmp_config_dir):
|
|
"""Detects nodes using a specific profile."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {
|
|
"router1": {
|
|
"host": "10.0.0.1", "protocol": "ssh", "port": "",
|
|
"user": "@myprofile", "password": "pass",
|
|
"options": "", "logs": "", "tags": "", "jumphost": "",
|
|
"type": "connection"
|
|
},
|
|
"router2": {
|
|
"host": "10.0.0.2", "protocol": "ssh", "port": "",
|
|
"user": "admin", "password": "pass",
|
|
"options": "", "logs": "", "tags": "", "jumphost": "",
|
|
"type": "connection"
|
|
}
|
|
},
|
|
"profiles": {
|
|
"default": {"host": "", "protocol": "ssh", "port": "",
|
|
"user": "", "password": "", "options": "",
|
|
"logs": "", "tags": "", "jumphost": ""},
|
|
"myprofile": {"host": "", "protocol": "ssh", "port": "",
|
|
"user": "profuser", "password": "profpass",
|
|
"options": "", "logs": "", "tags": "", "jumphost": ""}
|
|
}
|
|
}
|
|
config_file.write_text(yaml.dump(data, default_flow_style=False, sort_keys=False))
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(tmp_config_dir / ".osk"))
|
|
|
|
used = conf._profileused("myprofile")
|
|
assert "router1" in used
|
|
assert "router2" not in used
|
|
|
|
def test_saveconfig(self, config):
|
|
"""Save and reload correctly."""
|
|
config._connections_add(
|
|
id="test_node", host="1.2.3.4", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
result = config._saveconfig(config.file)
|
|
assert result == 0
|
|
|
|
# Reload and verify
|
|
from connpy.configfile import configfile
|
|
reloaded = configfile(conf=config.file, key=config.key)
|
|
assert "test_node" in reloaded.connections</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll.test_getallfolders"><code class="name flex">
|
|
<span>def <span class="ident">test_getallfolders</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getallfolders(self, populated_config):
|
|
folders = populated_config._getallfolders()
|
|
assert "@office" in folders
|
|
assert "@datacenter@office" in folders</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll.test_getallnodes_filter_invalid_type"><code class="name flex">
|
|
<span>def <span class="ident">test_getallnodes_filter_invalid_type</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getallnodes_filter_invalid_type(self, populated_config):
|
|
with pytest.raises(SystemExit) as exc:
|
|
populated_config._getallnodes(123)
|
|
assert exc.value.code == 1</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll.test_getallnodes_list_filter"><code class="name flex">
|
|
<span>def <span class="ident">test_getallnodes_list_filter</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getallnodes_list_filter(self, populated_config):
|
|
nodes = populated_config._getallnodes(["router.*", "db.*"])
|
|
assert "router1" in nodes
|
|
assert "db1@datacenter@office" in nodes
|
|
assert "server1@office" not in nodes</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll.test_getallnodes_no_filter"><code class="name flex">
|
|
<span>def <span class="ident">test_getallnodes_no_filter</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getallnodes_no_filter(self, populated_config):
|
|
nodes = populated_config._getallnodes()
|
|
assert "router1" in nodes
|
|
assert "server1@office" in nodes
|
|
assert "db1@datacenter@office" in nodes</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll.test_getallnodes_string_filter"><code class="name flex">
|
|
<span>def <span class="ident">test_getallnodes_string_filter</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getallnodes_string_filter(self, populated_config):
|
|
nodes = populated_config._getallnodes("router.*")
|
|
assert "router1" in nodes
|
|
assert "server1@office" not in nodes</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll.test_getallnodesfull"><code class="name flex">
|
|
<span>def <span class="ident">test_getallnodesfull</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getallnodesfull(self, populated_config):
|
|
nodes = populated_config._getallnodesfull()
|
|
assert "router1" in nodes
|
|
assert nodes["router1"]["host"] == "10.0.0.1"</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll.test_getallnodesfull_with_filter"><code class="name flex">
|
|
<span>def <span class="ident">test_getallnodesfull_with_filter</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getallnodesfull_with_filter(self, populated_config):
|
|
nodes = populated_config._getallnodesfull("router.*")
|
|
assert "router1" in nodes
|
|
assert "server1@office" not in nodes</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll.test_profileused"><code class="name flex">
|
|
<span>def <span class="ident">test_profileused</span></span>(<span>self, tmp_config_dir)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_profileused(self, tmp_config_dir):
|
|
"""Detects nodes using a specific profile."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {
|
|
"router1": {
|
|
"host": "10.0.0.1", "protocol": "ssh", "port": "",
|
|
"user": "@myprofile", "password": "pass",
|
|
"options": "", "logs": "", "tags": "", "jumphost": "",
|
|
"type": "connection"
|
|
},
|
|
"router2": {
|
|
"host": "10.0.0.2", "protocol": "ssh", "port": "",
|
|
"user": "admin", "password": "pass",
|
|
"options": "", "logs": "", "tags": "", "jumphost": "",
|
|
"type": "connection"
|
|
}
|
|
},
|
|
"profiles": {
|
|
"default": {"host": "", "protocol": "ssh", "port": "",
|
|
"user": "", "password": "", "options": "",
|
|
"logs": "", "tags": "", "jumphost": ""},
|
|
"myprofile": {"host": "", "protocol": "ssh", "port": "",
|
|
"user": "profuser", "password": "profpass",
|
|
"options": "", "logs": "", "tags": "", "jumphost": ""}
|
|
}
|
|
}
|
|
config_file.write_text(yaml.dump(data, default_flow_style=False, sort_keys=False))
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(tmp_config_dir / ".osk"))
|
|
|
|
used = conf._profileused("myprofile")
|
|
assert "router1" in used
|
|
assert "router2" not in used</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Detects nodes using a specific profile.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetAll.test_saveconfig"><code class="name flex">
|
|
<span>def <span class="ident">test_saveconfig</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_saveconfig(self, config):
|
|
"""Save and reload correctly."""
|
|
config._connections_add(
|
|
id="test_node", host="1.2.3.4", protocol="ssh",
|
|
port="", user="", password="", options="",
|
|
logs="", tags="", jumphost=""
|
|
)
|
|
result = config._saveconfig(config.file)
|
|
assert result == 0
|
|
|
|
# Reload and verify
|
|
from connpy.configfile import configfile
|
|
reloaded = configfile(conf=config.file, key=config.key)
|
|
assert "test_node" in reloaded.connections</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Save and reload correctly.</p></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetItem"><code class="flex name class">
|
|
<span>class <span class="ident">TestGetItem</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestGetItem:
|
|
def test_getitem_node(self, populated_config):
|
|
node = populated_config.getitem("router1")
|
|
assert node["host"] == "10.0.0.1"
|
|
assert "type" not in node # type is stripped
|
|
|
|
def test_getitem_folder(self, populated_config):
|
|
nodes = populated_config.getitem("@office")
|
|
# Should contain server1@office but NOT datacenter (subfolder)
|
|
assert "server1@office" in nodes
|
|
assert all("type" not in v for v in nodes.values())
|
|
|
|
def test_getitem_subfolder(self, populated_config):
|
|
nodes = populated_config.getitem("@datacenter@office")
|
|
assert "db1@datacenter@office" in nodes
|
|
|
|
def test_getitem_node_in_folder(self, populated_config):
|
|
node = populated_config.getitem("server1@office")
|
|
assert node["host"] == "10.0.1.1"
|
|
|
|
def test_getitem_node_in_subfolder(self, populated_config):
|
|
node = populated_config.getitem("db1@datacenter@office")
|
|
assert node["host"] == "10.0.2.1"
|
|
|
|
def test_getitem_with_profile_extraction(self, tmp_config_dir):
|
|
"""extract=True resolves @profile references."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {
|
|
"router1": {
|
|
"host": "10.0.0.1", "protocol": "ssh", "port": "",
|
|
"user": "@office-user", "password": "@office-user",
|
|
"options": "", "logs": "", "tags": "", "jumphost": "",
|
|
"type": "connection"
|
|
}
|
|
},
|
|
"profiles": {
|
|
"default": {"host": "", "protocol": "ssh", "port": "",
|
|
"user": "", "password": "", "options": "",
|
|
"logs": "", "tags": "", "jumphost": ""},
|
|
"office-user": {"host": "", "protocol": "ssh", "port": "",
|
|
"user": "officeadmin", "password": "officepass",
|
|
"options": "", "logs": "", "tags": "", "jumphost": ""}
|
|
}
|
|
}
|
|
config_file.write_text(yaml.dump(data, default_flow_style=False, sort_keys=False))
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(tmp_config_dir / ".osk"))
|
|
|
|
node = conf.getitem("router1", extract=True)
|
|
assert node["user"] == "officeadmin"
|
|
assert node["password"] == "officepass"
|
|
|
|
def test_getitems_multiple(self, populated_config):
|
|
nodes = populated_config.getitems(["router1", "server1@office"])
|
|
assert "router1" in nodes
|
|
assert "server1@office" in nodes
|
|
|
|
def test_getitems_folder(self, populated_config):
|
|
nodes = populated_config.getitems(["@office"])
|
|
assert "server1@office" in nodes</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestGetItem.test_getitem_folder"><code class="name flex">
|
|
<span>def <span class="ident">test_getitem_folder</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getitem_folder(self, populated_config):
|
|
nodes = populated_config.getitem("@office")
|
|
# Should contain server1@office but NOT datacenter (subfolder)
|
|
assert "server1@office" in nodes
|
|
assert all("type" not in v for v in nodes.values())</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetItem.test_getitem_node"><code class="name flex">
|
|
<span>def <span class="ident">test_getitem_node</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getitem_node(self, populated_config):
|
|
node = populated_config.getitem("router1")
|
|
assert node["host"] == "10.0.0.1"
|
|
assert "type" not in node # type is stripped</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetItem.test_getitem_node_in_folder"><code class="name flex">
|
|
<span>def <span class="ident">test_getitem_node_in_folder</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getitem_node_in_folder(self, populated_config):
|
|
node = populated_config.getitem("server1@office")
|
|
assert node["host"] == "10.0.1.1"</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetItem.test_getitem_node_in_subfolder"><code class="name flex">
|
|
<span>def <span class="ident">test_getitem_node_in_subfolder</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getitem_node_in_subfolder(self, populated_config):
|
|
node = populated_config.getitem("db1@datacenter@office")
|
|
assert node["host"] == "10.0.2.1"</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetItem.test_getitem_subfolder"><code class="name flex">
|
|
<span>def <span class="ident">test_getitem_subfolder</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getitem_subfolder(self, populated_config):
|
|
nodes = populated_config.getitem("@datacenter@office")
|
|
assert "db1@datacenter@office" in nodes</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetItem.test_getitem_with_profile_extraction"><code class="name flex">
|
|
<span>def <span class="ident">test_getitem_with_profile_extraction</span></span>(<span>self, tmp_config_dir)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getitem_with_profile_extraction(self, tmp_config_dir):
|
|
"""extract=True resolves @profile references."""
|
|
config_file = tmp_config_dir / "config.yaml"
|
|
data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {
|
|
"router1": {
|
|
"host": "10.0.0.1", "protocol": "ssh", "port": "",
|
|
"user": "@office-user", "password": "@office-user",
|
|
"options": "", "logs": "", "tags": "", "jumphost": "",
|
|
"type": "connection"
|
|
}
|
|
},
|
|
"profiles": {
|
|
"default": {"host": "", "protocol": "ssh", "port": "",
|
|
"user": "", "password": "", "options": "",
|
|
"logs": "", "tags": "", "jumphost": ""},
|
|
"office-user": {"host": "", "protocol": "ssh", "port": "",
|
|
"user": "officeadmin", "password": "officepass",
|
|
"options": "", "logs": "", "tags": "", "jumphost": ""}
|
|
}
|
|
}
|
|
config_file.write_text(yaml.dump(data, default_flow_style=False, sort_keys=False))
|
|
|
|
from connpy.configfile import configfile
|
|
conf = configfile(conf=str(config_file), key=str(tmp_config_dir / ".osk"))
|
|
|
|
node = conf.getitem("router1", extract=True)
|
|
assert node["user"] == "officeadmin"
|
|
assert node["password"] == "officepass"</code></pre>
|
|
</details>
|
|
<div class="desc"><p>extract=True resolves @profile references.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetItem.test_getitems_folder"><code class="name flex">
|
|
<span>def <span class="ident">test_getitems_folder</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getitems_folder(self, populated_config):
|
|
nodes = populated_config.getitems(["@office"])
|
|
assert "server1@office" in nodes</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestGetItem.test_getitems_multiple"><code class="name flex">
|
|
<span>def <span class="ident">test_getitems_multiple</span></span>(<span>self, populated_config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_getitems_multiple(self, populated_config):
|
|
nodes = populated_config.getitems(["router1", "server1@office"])
|
|
assert "router1" in nodes
|
|
assert "server1@office" in nodes</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestMigrationSafety"><code class="flex name class">
|
|
<span>class <span class="ident">TestMigrationSafety</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestMigrationSafety:
|
|
def test_migration_validates_legacy_data(self, tmp_path):
|
|
"""Migration skips invalid legacy JSON files."""
|
|
from unittest.mock import patch
|
|
config_dir = tmp_path / ".config" / "conn"
|
|
config_dir.mkdir(parents=True)
|
|
(config_dir / "plugins").mkdir()
|
|
|
|
# Write .folder
|
|
(config_dir / ".folder").write_text(str(config_dir))
|
|
|
|
# Generate RSA key
|
|
from Crypto.PublicKey import RSA
|
|
key = RSA.generate(2048)
|
|
key_file = config_dir / ".osk"
|
|
key_file.write_bytes(key.export_key("PEM"))
|
|
os.chmod(str(key_file), 0o600)
|
|
|
|
# Write invalid JSON config (missing required keys)
|
|
legacy_file = config_dir / "config.json"
|
|
legacy_file.write_text(json.dumps({"garbage": True}))
|
|
|
|
with patch("os.path.expanduser", return_value=str(tmp_path)):
|
|
from connpy.configfile import configfile
|
|
conf = configfile(key=str(key_file))
|
|
|
|
# Legacy file should NOT have been moved to .backup
|
|
assert legacy_file.exists()
|
|
assert not (config_dir / "config.json.backup").exists()
|
|
|
|
def test_migration_verifies_written_yaml(self, tmp_path):
|
|
"""Migration succeeds when legacy JSON is valid."""
|
|
from unittest.mock import patch
|
|
config_dir = tmp_path / ".config" / "conn"
|
|
config_dir.mkdir(parents=True)
|
|
(config_dir / "plugins").mkdir()
|
|
|
|
# Write .folder
|
|
(config_dir / ".folder").write_text(str(config_dir))
|
|
|
|
# Generate RSA key
|
|
from Crypto.PublicKey import RSA
|
|
key = RSA.generate(2048)
|
|
key_file = config_dir / ".osk"
|
|
key_file.write_bytes(key.export_key("PEM"))
|
|
os.chmod(str(key_file), 0o600)
|
|
|
|
valid_data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {"r1": {"host": "1.2.3.4", "type": "connection", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}},
|
|
"profiles": {"default": {"host": "", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}}
|
|
}
|
|
legacy_file = config_dir / "config.json"
|
|
legacy_file.write_text(json.dumps(valid_data))
|
|
|
|
with patch("os.path.expanduser", return_value=str(tmp_path)):
|
|
from connpy.configfile import configfile
|
|
conf = configfile(key=str(key_file))
|
|
|
|
# Migration should have succeeded: YAML exists, JSON backed up
|
|
yaml_file = config_dir / "config.yaml"
|
|
assert yaml_file.exists()
|
|
assert (config_dir / "config.json.backup").exists()
|
|
assert not legacy_file.exists()
|
|
assert "r1" in conf.connections</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestMigrationSafety.test_migration_validates_legacy_data"><code class="name flex">
|
|
<span>def <span class="ident">test_migration_validates_legacy_data</span></span>(<span>self, tmp_path)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_migration_validates_legacy_data(self, tmp_path):
|
|
"""Migration skips invalid legacy JSON files."""
|
|
from unittest.mock import patch
|
|
config_dir = tmp_path / ".config" / "conn"
|
|
config_dir.mkdir(parents=True)
|
|
(config_dir / "plugins").mkdir()
|
|
|
|
# Write .folder
|
|
(config_dir / ".folder").write_text(str(config_dir))
|
|
|
|
# Generate RSA key
|
|
from Crypto.PublicKey import RSA
|
|
key = RSA.generate(2048)
|
|
key_file = config_dir / ".osk"
|
|
key_file.write_bytes(key.export_key("PEM"))
|
|
os.chmod(str(key_file), 0o600)
|
|
|
|
# Write invalid JSON config (missing required keys)
|
|
legacy_file = config_dir / "config.json"
|
|
legacy_file.write_text(json.dumps({"garbage": True}))
|
|
|
|
with patch("os.path.expanduser", return_value=str(tmp_path)):
|
|
from connpy.configfile import configfile
|
|
conf = configfile(key=str(key_file))
|
|
|
|
# Legacy file should NOT have been moved to .backup
|
|
assert legacy_file.exists()
|
|
assert not (config_dir / "config.json.backup").exists()</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Migration skips invalid legacy JSON files.</p></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestMigrationSafety.test_migration_verifies_written_yaml"><code class="name flex">
|
|
<span>def <span class="ident">test_migration_verifies_written_yaml</span></span>(<span>self, tmp_path)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_migration_verifies_written_yaml(self, tmp_path):
|
|
"""Migration succeeds when legacy JSON is valid."""
|
|
from unittest.mock import patch
|
|
config_dir = tmp_path / ".config" / "conn"
|
|
config_dir.mkdir(parents=True)
|
|
(config_dir / "plugins").mkdir()
|
|
|
|
# Write .folder
|
|
(config_dir / ".folder").write_text(str(config_dir))
|
|
|
|
# Generate RSA key
|
|
from Crypto.PublicKey import RSA
|
|
key = RSA.generate(2048)
|
|
key_file = config_dir / ".osk"
|
|
key_file.write_bytes(key.export_key("PEM"))
|
|
os.chmod(str(key_file), 0o600)
|
|
|
|
valid_data = {
|
|
"config": {"case": False, "idletime": 30, "fzf": False},
|
|
"connections": {"r1": {"host": "1.2.3.4", "type": "connection", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}},
|
|
"profiles": {"default": {"host": "", "protocol": "ssh", "port": "", "user": "", "password": "", "options": "", "logs": "", "tags": "", "jumphost": ""}}
|
|
}
|
|
legacy_file = config_dir / "config.json"
|
|
legacy_file.write_text(json.dumps(valid_data))
|
|
|
|
with patch("os.path.expanduser", return_value=str(tmp_path)):
|
|
from connpy.configfile import configfile
|
|
conf = configfile(key=str(key_file))
|
|
|
|
# Migration should have succeeded: YAML exists, JSON backed up
|
|
yaml_file = config_dir / "config.yaml"
|
|
assert yaml_file.exists()
|
|
assert (config_dir / "config.json.backup").exists()
|
|
assert not legacy_file.exists()
|
|
assert "r1" in conf.connections</code></pre>
|
|
</details>
|
|
<div class="desc"><p>Migration succeeds when legacy JSON is valid.</p></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestValidateConfig"><code class="flex name class">
|
|
<span>class <span class="ident">TestValidateConfig</span></span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">class TestValidateConfig:
|
|
def test_valid_config(self, config):
|
|
data = {"config": {}, "connections": {}, "profiles": {}}
|
|
assert config._validate_config(data) == True
|
|
|
|
def test_none_data(self, config):
|
|
assert config._validate_config(None) == False
|
|
|
|
def test_string_data(self, config):
|
|
assert config._validate_config("not a dict") == False
|
|
|
|
def test_missing_key(self, config):
|
|
assert config._validate_config({"config": {}, "connections": {}}) == False
|
|
|
|
def test_empty_dict(self, config):
|
|
assert config._validate_config({}) == False</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
<h3>Methods</h3>
|
|
<dl>
|
|
<dt id="connpy.tests.test_configfile.TestValidateConfig.test_empty_dict"><code class="name flex">
|
|
<span>def <span class="ident">test_empty_dict</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_empty_dict(self, config):
|
|
assert config._validate_config({}) == False</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestValidateConfig.test_missing_key"><code class="name flex">
|
|
<span>def <span class="ident">test_missing_key</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_missing_key(self, config):
|
|
assert config._validate_config({"config": {}, "connections": {}}) == False</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestValidateConfig.test_none_data"><code class="name flex">
|
|
<span>def <span class="ident">test_none_data</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_none_data(self, config):
|
|
assert config._validate_config(None) == False</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestValidateConfig.test_string_data"><code class="name flex">
|
|
<span>def <span class="ident">test_string_data</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_string_data(self, config):
|
|
assert config._validate_config("not a dict") == False</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
<dt id="connpy.tests.test_configfile.TestValidateConfig.test_valid_config"><code class="name flex">
|
|
<span>def <span class="ident">test_valid_config</span></span>(<span>self, config)</span>
|
|
</code></dt>
|
|
<dd>
|
|
<details class="source">
|
|
<summary>
|
|
<span>Expand source code</span>
|
|
</summary>
|
|
<pre><code class="python">def test_valid_config(self, config):
|
|
data = {"config": {}, "connections": {}, "profiles": {}}
|
|
assert config._validate_config(data) == True</code></pre>
|
|
</details>
|
|
<div class="desc"></div>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
</dl>
|
|
</section>
|
|
</article>
|
|
<nav id="sidebar">
|
|
<div class="toc">
|
|
<ul></ul>
|
|
</div>
|
|
<ul id="index">
|
|
<li><h3>Super-module</h3>
|
|
<ul>
|
|
<li><code><a title="connpy.tests" href="index.html">connpy.tests</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li><h3><a href="#header-classes">Classes</a></h3>
|
|
<ul>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestAtomicSave" href="#connpy.tests.test_configfile.TestAtomicSave">TestAtomicSave</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestAtomicSave.test_save_creates_no_leftover_tmp" href="#connpy.tests.test_configfile.TestAtomicSave.test_save_creates_no_leftover_tmp">test_save_creates_no_leftover_tmp</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestAtomicSave.test_save_preserves_original_on_error" href="#connpy.tests.test_configfile.TestAtomicSave.test_save_preserves_original_on_error">test_save_preserves_original_on_error</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestCRUDNodes" href="#connpy.tests.test_configfile.TestCRUDNodes">TestCRUDNodes</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDNodes.test_add_folder" href="#connpy.tests.test_configfile.TestCRUDNodes.test_add_folder">test_add_folder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDNodes.test_add_node_folder" href="#connpy.tests.test_configfile.TestCRUDNodes.test_add_node_folder">test_add_node_folder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDNodes.test_add_node_root" href="#connpy.tests.test_configfile.TestCRUDNodes.test_add_node_root">test_add_node_root</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDNodes.test_add_node_subfolder" href="#connpy.tests.test_configfile.TestCRUDNodes.test_add_node_subfolder">test_add_node_subfolder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDNodes.test_add_subfolder" href="#connpy.tests.test_configfile.TestCRUDNodes.test_add_subfolder">test_add_subfolder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDNodes.test_del_folder" href="#connpy.tests.test_configfile.TestCRUDNodes.test_del_folder">test_del_folder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDNodes.test_del_node_folder" href="#connpy.tests.test_configfile.TestCRUDNodes.test_del_node_folder">test_del_node_folder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDNodes.test_del_node_root" href="#connpy.tests.test_configfile.TestCRUDNodes.test_del_node_root">test_del_node_root</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDNodes.test_del_subfolder" href="#connpy.tests.test_configfile.TestCRUDNodes.test_del_subfolder">test_del_subfolder</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestCRUDProfiles" href="#connpy.tests.test_configfile.TestCRUDProfiles">TestCRUDProfiles</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDProfiles.test_add_profile" href="#connpy.tests.test_configfile.TestCRUDProfiles.test_add_profile">test_add_profile</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDProfiles.test_default_profile_exists" href="#connpy.tests.test_configfile.TestCRUDProfiles.test_default_profile_exists">test_default_profile_exists</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCRUDProfiles.test_del_profile" href="#connpy.tests.test_configfile.TestCRUDProfiles.test_del_profile">test_del_profile</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestConfigfileInit" href="#connpy.tests.test_configfile.TestConfigfileInit">TestConfigfileInit</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestConfigfileInit.test_config_file_permissions" href="#connpy.tests.test_configfile.TestConfigfileInit.test_config_file_permissions">test_config_file_permissions</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestConfigfileInit.test_creates_default_config" href="#connpy.tests.test_configfile.TestConfigfileInit.test_creates_default_config">test_creates_default_config</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestConfigfileInit.test_creates_rsa_key" href="#connpy.tests.test_configfile.TestConfigfileInit.test_creates_rsa_key">test_creates_rsa_key</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestConfigfileInit.test_custom_paths" href="#connpy.tests.test_configfile.TestConfigfileInit.test_custom_paths">test_custom_paths</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestConfigfileInit.test_loads_existing_config" href="#connpy.tests.test_configfile.TestConfigfileInit.test_loads_existing_config">test_loads_existing_config</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestCorruptionRecovery" href="#connpy.tests.test_configfile.TestCorruptionRecovery">TestCorruptionRecovery</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestCorruptionRecovery.test_both_corrupt_creates_default" href="#connpy.tests.test_configfile.TestCorruptionRecovery.test_both_corrupt_creates_default">test_both_corrupt_creates_default</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCorruptionRecovery.test_corrupt_cache_uses_yaml" href="#connpy.tests.test_configfile.TestCorruptionRecovery.test_corrupt_cache_uses_yaml">test_corrupt_cache_uses_yaml</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestCorruptionRecovery.test_corrupt_yaml_recovers_from_cache" href="#connpy.tests.test_configfile.TestCorruptionRecovery.test_corrupt_yaml_recovers_from_cache">test_corrupt_yaml_recovers_from_cache</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestEncryption" href="#connpy.tests.test_configfile.TestEncryption">TestEncryption</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestEncryption.test_encrypt_decrypt_roundtrip" href="#connpy.tests.test_configfile.TestEncryption.test_encrypt_decrypt_roundtrip">test_encrypt_decrypt_roundtrip</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestEncryption.test_encrypt_password" href="#connpy.tests.test_configfile.TestEncryption.test_encrypt_password">test_encrypt_password</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestExplodeUnique" href="#connpy.tests.test_configfile.TestExplodeUnique">TestExplodeUnique</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestExplodeUnique.test_empty_folder" href="#connpy.tests.test_configfile.TestExplodeUnique.test_empty_folder">test_empty_folder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestExplodeUnique.test_empty_subfolder" href="#connpy.tests.test_configfile.TestExplodeUnique.test_empty_subfolder">test_empty_subfolder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestExplodeUnique.test_folder_only" href="#connpy.tests.test_configfile.TestExplodeUnique.test_folder_only">test_folder_only</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestExplodeUnique.test_node_with_folder" href="#connpy.tests.test_configfile.TestExplodeUnique.test_node_with_folder">test_node_with_folder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestExplodeUnique.test_node_with_subfolder" href="#connpy.tests.test_configfile.TestExplodeUnique.test_node_with_subfolder">test_node_with_subfolder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestExplodeUnique.test_simple_node" href="#connpy.tests.test_configfile.TestExplodeUnique.test_simple_node">test_simple_node</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestExplodeUnique.test_subfolder_only" href="#connpy.tests.test_configfile.TestExplodeUnique.test_subfolder_only">test_subfolder_only</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestExplodeUnique.test_too_deep" href="#connpy.tests.test_configfile.TestExplodeUnique.test_too_deep">test_too_deep</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestGetAll" href="#connpy.tests.test_configfile.TestGetAll">TestGetAll</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetAll.test_getallfolders" href="#connpy.tests.test_configfile.TestGetAll.test_getallfolders">test_getallfolders</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetAll.test_getallnodes_filter_invalid_type" href="#connpy.tests.test_configfile.TestGetAll.test_getallnodes_filter_invalid_type">test_getallnodes_filter_invalid_type</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetAll.test_getallnodes_list_filter" href="#connpy.tests.test_configfile.TestGetAll.test_getallnodes_list_filter">test_getallnodes_list_filter</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetAll.test_getallnodes_no_filter" href="#connpy.tests.test_configfile.TestGetAll.test_getallnodes_no_filter">test_getallnodes_no_filter</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetAll.test_getallnodes_string_filter" href="#connpy.tests.test_configfile.TestGetAll.test_getallnodes_string_filter">test_getallnodes_string_filter</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetAll.test_getallnodesfull" href="#connpy.tests.test_configfile.TestGetAll.test_getallnodesfull">test_getallnodesfull</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetAll.test_getallnodesfull_with_filter" href="#connpy.tests.test_configfile.TestGetAll.test_getallnodesfull_with_filter">test_getallnodesfull_with_filter</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetAll.test_profileused" href="#connpy.tests.test_configfile.TestGetAll.test_profileused">test_profileused</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetAll.test_saveconfig" href="#connpy.tests.test_configfile.TestGetAll.test_saveconfig">test_saveconfig</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestGetItem" href="#connpy.tests.test_configfile.TestGetItem">TestGetItem</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetItem.test_getitem_folder" href="#connpy.tests.test_configfile.TestGetItem.test_getitem_folder">test_getitem_folder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetItem.test_getitem_node" href="#connpy.tests.test_configfile.TestGetItem.test_getitem_node">test_getitem_node</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetItem.test_getitem_node_in_folder" href="#connpy.tests.test_configfile.TestGetItem.test_getitem_node_in_folder">test_getitem_node_in_folder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetItem.test_getitem_node_in_subfolder" href="#connpy.tests.test_configfile.TestGetItem.test_getitem_node_in_subfolder">test_getitem_node_in_subfolder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetItem.test_getitem_subfolder" href="#connpy.tests.test_configfile.TestGetItem.test_getitem_subfolder">test_getitem_subfolder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetItem.test_getitem_with_profile_extraction" href="#connpy.tests.test_configfile.TestGetItem.test_getitem_with_profile_extraction">test_getitem_with_profile_extraction</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetItem.test_getitems_folder" href="#connpy.tests.test_configfile.TestGetItem.test_getitems_folder">test_getitems_folder</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestGetItem.test_getitems_multiple" href="#connpy.tests.test_configfile.TestGetItem.test_getitems_multiple">test_getitems_multiple</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestMigrationSafety" href="#connpy.tests.test_configfile.TestMigrationSafety">TestMigrationSafety</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestMigrationSafety.test_migration_validates_legacy_data" href="#connpy.tests.test_configfile.TestMigrationSafety.test_migration_validates_legacy_data">test_migration_validates_legacy_data</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestMigrationSafety.test_migration_verifies_written_yaml" href="#connpy.tests.test_configfile.TestMigrationSafety.test_migration_verifies_written_yaml">test_migration_verifies_written_yaml</a></code></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<h4><code><a title="connpy.tests.test_configfile.TestValidateConfig" href="#connpy.tests.test_configfile.TestValidateConfig">TestValidateConfig</a></code></h4>
|
|
<ul class="">
|
|
<li><code><a title="connpy.tests.test_configfile.TestValidateConfig.test_empty_dict" href="#connpy.tests.test_configfile.TestValidateConfig.test_empty_dict">test_empty_dict</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestValidateConfig.test_missing_key" href="#connpy.tests.test_configfile.TestValidateConfig.test_missing_key">test_missing_key</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestValidateConfig.test_none_data" href="#connpy.tests.test_configfile.TestValidateConfig.test_none_data">test_none_data</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestValidateConfig.test_string_data" href="#connpy.tests.test_configfile.TestValidateConfig.test_string_data">test_string_data</a></code></li>
|
|
<li><code><a title="connpy.tests.test_configfile.TestValidateConfig.test_valid_config" href="#connpy.tests.test_configfile.TestValidateConfig.test_valid_config">test_valid_config</a></code></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</main>
|
|
<footer id="footer">
|
|
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.11.6</a>.</p>
|
|
</footer>
|
|
</body>
|
|
</html>
|