20 Commits

Author SHA1 Message Date
3wc
13b2c05476 gitignore unittest output file 2021-08-16 02:07:36 +02:00
5f9fc1adcf create TestHTTPClient that uses werkzueg test client, tests are passing 2021-08-16 02:07:36 +02:00
16ff1b5b26 documenting the janky tests logs situation 2021-08-16 02:07:36 +02:00
8c10f71f58 getting unit tests to log properly 2021-08-16 02:07:36 +02:00
66dee4d87a breaking up after abusive relationship with logger 2021-08-16 02:07:36 +02:00
6a587ac7fc trying to do CaptureLogOutputDuringTestsFilter (but no worky yet) 2021-08-16 02:07:36 +02:00
4e510ebb01 blah failed attempts at getting tests to log 2021-08-16 02:07:36 +02:00
140870ec35 add debug test log 2021-08-16 02:07:36 +02:00
2348191990 trying to get tests to pass with hub_model=capsulflask 2021-08-16 02:07:36 +02:00
5e682cc705 remove redundant get_vms() and add testing documentation from pull
request
2021-08-16 02:07:36 +02:00
3wc
2b33573890 Fix capsul create tests, post-test cleanup, tidy merge 2021-08-16 02:07:36 +02:00
da4d28f70c ensure that app is defined in app.py to fix login link logging issues.
also shuffled some things around for cleanliness
2021-08-16 02:07:36 +02:00
3wc
d833b3df19 Disable VM creation check for the moment 2021-08-16 02:07:36 +02:00
3wc
46a40261bb Add SSH key tests 2021-08-16 02:07:36 +02:00
3wc
b108d4c04e Initial console tests
NB capsul create isn't working properly, see #83
2021-08-16 02:07:36 +02:00
3wc
6bd02a660e Basic testing using flask-testing
This commit makes it possible to override settings during tests, by
switching capsulflask/__init__.py to a "create_app" pattern, and using
`dotenv_values` instead of `load_dotenv`.

The create_app() method returns a Flask app instance, to give
more control over when to initialise the app. This allows setting
environment variables in test files.

Then, use dotenv_values to override loaded .env variables with ones from
the environment, so that tests can set `POSTGRES_CONNECTION_PARAMETERS`
and `SPOKE_MODEL` (possibly others in future..).

Inital tests for the "landing" pages, and login / activation, are
included.
2021-08-16 02:07:34 +02:00
8a944104d3 Merge pull request 'Make the displayed SSH username configurable' (#12) from mirsal/capsul-flask:ssh-username into master
Reviewed-on: 3wordchant/capsul-flask#12
2021-08-10 11:56:14 +02:00
d4a9f2f40a Make the displayed SSH username configurable
This patch allows the SSH username displayed in templates to be
configured through the SSH_USERNAME environment variable.
2021-08-10 00:30:45 +00:00
7b16606b16 Merge pull request 'shell_scripts: Fix reporting of VM IP addresses' (#9) from mirsal/capsul-flask:ipv6 into master
Reviewed-on: 3wordchant/capsul-flask#9
2021-08-04 12:13:44 +02:00
d9f3e68278 shell_scripts: Fix reporting of VM IP addresses
The shell script which gets informations from libvirt incorrectly
matches virsh output lines which contain VMs' public IPv4 addresses.
It doesn't work when there are multiple address families which breaks
reporting of IPv4 address when a VM also has an IPv6 address and virsh
happen to output that one first.

This commit changes it to explicitely match the first ipv4 address instead.
2021-08-04 00:56:55 +00:00
6 changed files with 9 additions and 6 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@ instance/
.pytest_cache/ .pytest_cache/
.coverage .coverage
htmlcov/ htmlcov/
/unittest-log-output.log
dist/ dist/
build/ build/

View File

@ -108,6 +108,8 @@ def detail(id):
if vm is None: if vm is None:
return abort(404, f"{id} doesn't exist.") return abort(404, f"{id} doesn't exist.")
vm['ssh_username'] = current_app.config['SSH_USERNAME']
if vm['deleted']: if vm['deleted']:
return render_template("capsul-detail.html", vm=vm, delete=True, deleted=True) return render_template("capsul-detail.html", vm=vm, delete=True, deleted=True)

View File

@ -23,7 +23,7 @@ def pricing():
@bp.route("/faq") @bp.route("/faq")
def faq(): def faq():
return render_template("faq.html") return render_template("faq.html", ssh_username=current_app.config['SSH_USERNAME'])
@bp.route("/about-ssh") @bp.route("/about-ssh")
def about_ssh(): def about_ssh():

View File

@ -30,6 +30,6 @@ if virsh domuuid "$vmname" | grep -vqE '^[\t\s\n]*$'; then
fi fi
# this gets the ipv4 # this gets the ipv4
ipv4="$(virsh domifaddr "$vmname" | awk '/vnet/ {print $4}' | cut -d'/' -f1)" ipv4="$(virsh domifaddr "$vmname" | awk '/ipv4/ {print $4}' | cut -d'/' -f1)"
echo "$exists $state $ipv4" echo "$exists $state $ipv4"

View File

@ -97,7 +97,7 @@
</div> </div>
<div class="row justify-start"> <div class="row justify-start">
<label class="align" for="ssh_username">SSH Username</label> <label class="align" for="ssh_username">SSH Username</label>
<span id="ssh_username">cyberian</span> <span id="ssh_username">{{ vm['ssh_username'] }}</span>
</div> </div>
<div class="row justify-start"> <div class="row justify-start">
<label class="align" for="ssh_authorized_keys">SSH Authorized Keys</label> <label class="align" for="ssh_authorized_keys">SSH Authorized Keys</label>

View File

@ -21,13 +21,13 @@
</li> </li>
<li> <li>
How do I log in? How do I log in?
<p>ssh to the ip provided to you using the cyberian user.</p> <p>ssh to the ip provided to you using the "{{ ssh_username }}" user.</p>
<pre class='code'>$ ssh cyberian@1.2.3.4</pre> <pre class='code'>$ ssh {{ ssh_username }}@1.2.3.4</pre>
<p>For more information, see <a href="/about-ssh">Understanding the Secure Shell Protocol (SSH)</a>.</p> <p>For more information, see <a href="/about-ssh">Understanding the Secure Shell Protocol (SSH)</a>.</p>
</li> </li>
<li> <li>
How do I change to the root user? How do I change to the root user?
<p>The cyberian user has passwordless sudo access by default. This should work:</p> <p>The "{{ ssh_username }}" user has passwordless sudo access by default. This should work:</p>
<pre class='code'> <pre class='code'>
# Linux # Linux
$ sudo su - $ sudo su -