Merge branch 'testing' into feature/3702-update-binding

This commit is contained in:
Cayo Puigdefabregas 2022-08-12 16:12:00 +02:00
commit ee754f6c64
10 changed files with 170 additions and 46 deletions

View File

@ -23,3 +23,6 @@
padding-top: 0px;
padding-bottom: 5px;
}
.help {
color: #993365;
}

View File

@ -1 +0,0 @@
868e59911be73a941938644143d81f21a2fdbe82ea0841493c2d9fc04701e058334af5fecd69c1a1525ebd5c8c17ac3f49d8ecc53bbfc8a018f169be48fe79d6 USODY_2022.5.2-beta.iso

View File

@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>{% block page_title %}{% endblock %} - USOdy</title>
<title>{% block page_title %}{% endblock %} - Usody</title>
<meta content="" name="description">
<meta content="" name="keywords">

View File

@ -95,7 +95,7 @@
<li>
<a class="dropdown-item d-flex align-items-center" href="{{ url_for('workbench.settings') }}">
<i class="bi bi-tools"></i>
<span>Workbench</span>
<span>Setup</span>
</a>
</li>
<li>
@ -283,7 +283,7 @@
<!-- ======= Footer ======= -->
<footer id="footer" class="footer">
<div class="copyright">
&copy; Copyright <strong><span>USOdy</span></strong>. All Rights Reserved
&copy; Copyright <strong><span>Usody</span></strong>. All Rights Reserved
</div>
<div class="credits">
<!-- All the links in the footer should remain intact. -->

View File

@ -18,31 +18,32 @@
<div class="card-body">
<div class="pt-6 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Download your settings for Workbench</h5>
{% if not demo %}
<div class="row pt-3">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=register" class="btn btn-primary">Register devices</a>
</div>
<div class="col">
<p class="small">Download the settings only for register devices.</p>
<p>Please download the ISO file and the settings file of the
version you want and follow these steps
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">steps</a></p>
</div>
</div>
{% if iso %}
<div class="row pt-3">
<div class="col-5">
<a href="/static/iso/{{ iso }}" class="btn btn-primary">{{ iso }}</a>
</div>
<div class="col">
<p class="small">
Download Checksum: <a style="color: #993365;" href="/static/iso/SHA512SUMS">SHA512SUMS</a>
</p>
</div>
</div>
{% endif %}
{% else %}
</div>
</div>
<div class="col-xl-8">
</div>
</div>
{% if demo %}
<div class="row">
<div class="col-xl-6">
<div class="card">
<div class="card-body">
<div class="pt-6 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Workbench 2022</h5>
{% if iso %}
<div class="row pt-3">
<div class="col-5">
@ -50,22 +51,97 @@
</div>
<div class="col">
<p class="small">
Download Checksum: <a style="color: #993365;" href="/static/iso/demo/SHA512SUMS">SHA512SUMS</a>
Download Checksum: <a class="help" href="/static/iso/demo/SHA512SUMS">SHA512SUMS</a> |
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
</p>
</div>
</div>
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-8">
</div>
</div>
{% else %}
{% for d, v in iso.items() %}
{% if d != 'demo' %}
<div class="row">
<div class="col-xl-6">
<div class="card">
<div class="card-body">
<div class="pt-6 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Workbench {{ d }}</h5>
{% if d == 'v14' %}
<div class="row">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=erease_basic" class="btn btn-primary" style="width: 200px;">Get settings file!</a>
</div>
<div class="col">
<p class="small">
Settings for basic data erasure. | <a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a>
</p>
</div>
</div>
<div class="row pt-2">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=erease_sectors" class="btn btn-primary" style="width: 200px;">Get settings file!</a>
</div>
<div class="col">
<p class="small">
Settings for advanced data erasure through sectors and hidden areas. Guarantee of data removal. | <a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a>
</p>
</div>
</div>
{% else %}
<div class="row">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=register" class="btn btn-primary" style="width: 200px;">Get settings file!</a>
</div>
<div class="col">
<p class="small">
Settings for register devices.
</p>
</div>
</div>
{% endif %}
{% if iso %}
<br />
<div class="row">
<div class="col-5">
<a href="/static/iso/{{ d }}/{{ v }}" class="btn btn-primary" style="width: 200px;">Get ISO file</a>
</div>
<div class="col">
<p class="small">
{{ v }}
</p>
<p class="small">
Download Checksum: <a class="help" href="/static/iso/{{ d }}/SHA512SUMS">SHA512SUMS</a> |
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
</p>
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<div class="col-xl-8">
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
</section>
{% endblock main %}

View File

@ -2,3 +2,33 @@
DH_TOKEN = {{ token }}
DH_URL = {{ url }}
{% if erease_basic %}
DH_HOST = {{ host }}
DH_DATABASE = {{ schema }}
DEVICEHUB_URL = https://${DB_HOST}/${DB_DATABASE}/
WB_BENCHMARK = True
WB_STRESS_TEST = 0
WB_SMART_TEST = short
WB_ERASE = EraseBasic
WB_ERASE_STEPS = 1
WB_ERASE_LEADING_ZEROS = False
WB_DEBUG = True
{% endif %}
{% if erease_sectors %}
DH_HOST = {{ host }}
DH_DATABASE = {{ schema }}
DEVICEHUB_URL = https://${DB_HOST}/${DB_DATABASE}/
WB_BENCHMARK = True
WB_STRESS_TEST = 0
WB_SMART_TEST = short
WB_ERASE = EraseSectors
WB_ERASE_STEPS = 1
WB_ERASE_LEADING_ZEROS = True
WB_DEBUG = True
{% endif %}

View File

@ -20,7 +20,7 @@ workbench = Blueprint('workbench', __name__, url_prefix='/workbench')
class SettingsView(GenericMixin):
decorators = [login_required]
template_name = 'workbench/settings.html'
page_title = "Workbench Settings"
page_title = "Workbench"
def dispatch_request(self):
self.get_context()
@ -33,7 +33,7 @@ class SettingsView(GenericMixin):
self.get_iso()
self.opt = request.values.get('opt')
if self.opt in ['register']:
if self.opt in ['register', 'erease_basic', 'erease_sectors']:
return self.download()
return flask.render_template(self.template_name, **self.context)
@ -44,27 +44,44 @@ class SettingsView(GenericMixin):
if self.context.get('demo'):
uri = f'{path}/static/iso/demo/'
files = [
f for f in os.listdir(uri) if f[-3:].lower() == 'iso'
]
self.context['iso'] = {}
self.context['iso'] = ''
self.context['iso_sha'] = ''
if not os.path.exists(uri):
return
versions = os.listdir(f'{path}/static/iso/')
versions.sort()
for d in versions:
dir_iso = f'{uri}/{d}'
if not os.path.isdir(dir_iso):
continue
files = [f for f in os.listdir(dir_iso) if f[-3:].lower() == 'iso']
if files:
self.context['iso'] = files[0]
self.context['iso_sha'] = 'aaa'
self.context['iso'][f'{d}'] = files[0]
def download(self):
url = "https://{}/api/inventory/".format(app.config['HOST'])
self.wbContext = {
'token': self.get_token(),
'url': url,
'erease_basic': None,
'erease_sectors': None,
}
options = {"register": self.register}
return options[self.opt]()
# if is a v14 version
# TODO when not use more v14, we can remove this if
if 'erease' in self.opt:
url = "https://{}/actions/".format(app.config['HOST'])
self.wbContext['url'] = url
self.wbContext['host'] = app.config['HOST']
self.wbContext['schema'] = app.config['SCHEMA']
if self.opt == 'erease_basic':
self.wbContext['erease_basic'] = True
if self.opt == 'erease_sectors':
self.wbContext['erease_sectors'] = True
def register(self):
data = flask.render_template('workbench/wbSettings.ini', **self.wbContext)
return self.response_download(data)
@ -94,4 +111,4 @@ class SettingsView(GenericMixin):
return token
workbench.add_url_rule('/settings/', view_func=SettingsView.as_view('settings'))
workbench.add_url_rule('/', view_func=SettingsView.as_view('settings'))

View File

@ -100,7 +100,7 @@ def test_api_docs(client: Client):
'/users/login/',
'/users/logout/',
'/versions/',
'/workbench/settings/',
'/workbench/',
}
assert docs['info'] == {'title': 'Devicehub', 'version': '0.2'}
assert docs['components']['securitySchemes']['bearerAuth'] == {

View File

@ -1282,18 +1282,17 @@ def test_action_datawipe(user3: UserClientFlask):
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_wb_settings(user3: UserClientFlask):
uri = '/workbench/settings/'
uri = '/workbench/'
body, status = user3.get(uri)
assert status == '200 OK'
assert "Download your settings for Workbench" in body
assert "Workbench Settings" in body
assert "Please download the ISO file and the settings file of the" in body
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_wb_settings_register(user3: UserClientFlask):
uri = '/workbench/settings/?opt=register'
uri = '/workbench/?opt=register'
body, status = user3.get(uri)
assert status == '200 OK'