Project

General

Profile

Bug #34885

Ensure ui_protocol is uppercase in /system/general/ API

Added by Eric Turgeon over 1 year ago. Updated over 1 year ago.

Status:
Done
Priority:
No priority
Assignee:
William Grzybowski
Category:
Middleware
Target version:
Severity:
Medium
Reason for Closing:
Reason for Blocked:
Needs QA:
No
Needs Doc:
No
Needs Merging:
No
Needs Automation:
No
Support Suite Ticket:
n/a
Hardware Configuration:
ChangeLog Required:
No

Description

From an ixautomation fresh installation.

platform freebsd12 -- Python 3.6.5, pytest-3.4.2, py-1.5.3, pluggy-0.6.0 -- /usr/local/bin/python3.6
cachedir: .pytest_cache
rootdir: /usr/home/ericbsd/projects/freenas/freenas/tests, inifile:
collected 10 items                                                                                                           

api2/system_general.py::test_01_get_system_general PASSED                                                              [ 10%]
api2/system_general.py::test_02_get_system_general_language_choices PASSED                                             [ 20%]
api2/system_general.py::test_03_get_system_general_timezone_choices PASSED                                             [ 30%]
api2/system_general.py::test_04_get_system_general_country_choices PASSED                                              [ 40%]
api2/system_general.py::test_05_get_system_general_kbdmap_choices PASSED                                               [ 50%]
api2/system_general.py::test_06_Setting_timezone FAILED                                                                [ 60%]
api2/system_general.py::test_07_Checking_timezone_using_api FAILED                                                     [ 70%]
api2/system_general.py::test_08_Checking_timezone_using_ssh FAILED                                                     [ 80%]
api2/system_general.py::test_09_Setting_sysloglevel FAILED                                                             [ 90%]
api2/system_general.py::test_10_Checking_sysloglevel_using_api FAILED                                                  [100%]

-------- generated xml file: /usr/home/ericbsd/projects/freenas/freenas/tests/results/system_general_tests_result.xml --------
========================================================== FAILURES ==========================================================
__________________________________________________ test_06_Setting_timezone __________________________________________________

    def test_06_Setting_timezone():
        results = PUT("/system/general/", {"timezone": TIMEZONE})
>       assert results.status_code == 200, results.text
E       AssertionError: {
E          "general_settings_update.ui_certificate": [
E           {
E            "message": "Protocol has been selected as HTTPS, certificate is required",
E            "errno": 22
E           }
E          ]
E         }
E       assert 422 == 200
E        +  where 422 = <Response [422]>.status_code

api2/system_general.py:53: AssertionError
____________________________________________ test_07_Checking_timezone_using_api _____________________________________________

    def test_07_Checking_timezone_using_api():
        results = GET("/system/general/")
        assert results.status_code == 200, results.text
        data = results.json()
>       assert data['timezone'] == TIMEZONE
E       AssertionError: assert 'America/Los_Angeles' == 'America/New_York'
E         - America/Los_Angeles
E         + America/New_York

api2/system_general.py:60: AssertionError
____________________________________________ test_08_Checking_timezone_using_ssh _____________________________________________

    def test_08_Checking_timezone_using_ssh():
        results = SSH_TEST(f'diff /etc/localtime /usr/share/zoneinfo/{TIMEZONE}', user, password, ip)
>       assert results['result'] is True, results
E       AssertionError: {'output': 'Files /etc/localtime and /usr/share/zoneinfo/America/New_York differ
E         ', 'result': False}
E       assert False is True

api2/system_general.py:65: AssertionError
---------------------------------------------------- Captured stderr call ----------------------------------------------------
Warning: Permanently added '192.168.2.216' (ECDSA) to the list of known hosts.
________________________________________________ test_09_Setting_sysloglevel _________________________________________________

    def test_09_Setting_sysloglevel():
        results = PUT("/system/general/", {"sysloglevel": SYSLOGLEVEL})
>       assert results.status_code == 200, results.text
E       AssertionError: {
E          "general_settings_update.ui_certificate": [
E           {
E            "message": "Protocol has been selected as HTTPS, certificate is required",
E            "errno": 22
E           }
E          ]
E         }
E       assert 422 == 200
E        +  where 422 = <Response [422]>.status_code

api2/system_general.py:70: AssertionError
___________________________________________ test_10_Checking_sysloglevel_using_api ___________________________________________

    def test_10_Checking_sysloglevel_using_api():
        results = GET("/system/general/")
        assert results.status_code == 200, results.text
        data = results.json()
>       assert data['sysloglevel'] == SYSLOGLEVEL
E       AssertionError: assert 'F_INFO' == 'F_CRIT'
E         - F_INFO
E         + F_CRIT

api2/system_general.py:77: AssertionError
============================================= 5 failed, 5 passed in 1.24 seconds =============================================

IPython output

In [1]: from functions import POST, DELETE, GET, PUT

In [2]: GET('/system/general/').text
Out[2]: '{\n "id": 1,\n "language": "en",\n "kbdmap": "",\n "timezone": "America/Los_Angeles",\n "sysloglevel": "F_INFO",\n "syslogserver": "",\n "wizardshown": false,\n "pwenc_check": "d3wJgu7eLujuoXOWiYKVCxy6ArM3HVTSjDFNVpudCF4qnG/H0JYaMA==",\n "ui_protocol": "http",\n "ui_certificate": null,\n "ui_address": "0.0.0.0",\n "ui_v6address": "::",\n "ui_port": 80,\n "ui_httpsport": 443,\n "ui_httpsredirect": true\n}'

In [3]: GET('/system/general/').json()
Out[3]: 
{'id': 1,
 'kbdmap': '',
 'language': 'en',
 'pwenc_check': 'd3wJgu7eLujuoXOWiYKVCxy6ArM3HVTSjDFNVpudCF4qnG/H0JYaMA==',
 'sysloglevel': 'F_INFO',
 'syslogserver': '',
 'timezone': 'America/Los_Angeles',
 'ui_address': '0.0.0.0',
 'ui_certificate': None,
 'ui_httpsport': 443,
 'ui_httpsredirect': True,
 'ui_port': 80,
 'ui_protocol': 'http',
 'ui_v6address': '::',
 'wizardshown': False}

In [4]: PUT("/system/general/", {'ui_httpsredirect': False, "timezone": TIMEZONE}).text
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-3647bda9eabc> in <module>()
----> 1 PUT("/system/general/", {'ui_httpsredirect': False, "timezone": TIMEZONE}).text

NameError: name 'TIMEZONE' is not defined

In [5]: PUT("/system/general/", {'ui_httpsredirect': False, "timezone": 'America/New_York'}).text
Out[5]: '{\n "general_settings_update.ui_certificate": [\n  {\n   "message": "Protocol has been selected as HTTPS, certificate is required",\n   "errno": 22\n  }\n ]\n}'

In [6]: PUT("/system/general/", {'ui_httpsredirect': True}).text
Out[6]: '{\n "general_settings_update.ui_certificate": [\n  {\n   "message": "Protocol has been selected as HTTPS, certificate is required",\n   "errno": 22\n  }\n ]\n}'

In [7]: PUT("/system/general/", {'ui_httpsredirect': False}).text
Out[7]: '{\n "general_settings_update.ui_certificate": [\n  {\n   "message": "Protocol has been selected as HTTPS, certificate is required",\n   "errno": 22\n  }\n ]\n}'

In [8]: PUT("/system/general/", {'ui_httpsredirect': True}).text
Out[8]: '{\n "general_settings_update.ui_certificate": [\n  {\n   "message": "Protocol has been selected as HTTPS, certificate is required",\n   "errno": 22\n  }\n ]\n}'

Associated revisions

Revision ffffb7c6 (diff)
Added by William Grzybowski over 1 year ago

fix(middlewared): `ui_protocol` should be uppercase Ticket: #34885

Revision 85721be6 (diff)
Added by William Grzybowski over 1 year ago

fix(middlewared): `ui_protocol` should be uppercase Ticket: #34885

Revision 4050642e (diff)
Added by William Grzybowski over 1 year ago

fix(middlewared): `ui_protocol` should be uppercase Ticket: #34885

History

#1 Updated by Dru Lavigne over 1 year ago

  • Assignee changed from Release Council to William Grzybowski

#2 Updated by William Grzybowski over 1 year ago

  • Status changed from Unscreened to In Progress
  • Target version changed from Backlog to 11.2-BETA1
  • Severity changed from New to Medium
  • Needs Merging changed from Yes to No

#3 Updated by William Grzybowski over 1 year ago

#4 Updated by William Grzybowski over 1 year ago

  • Status changed from In Progress to Ready for Testing

#5 Updated by Dru Lavigne over 1 year ago

  • Subject changed from REST API 2.0 PUT /system/general/ failed with Protocol has been selected as HTTPS, certificate is required. to Ensure ui_protocol is uppercase in /system/general/ API

#6 Updated by Eric Turgeon over 1 year ago

  • Needs QA changed from Yes to No

fixed all tests are working well.

==================================================== test session starts =====================================================
platform freebsd12 -- Python 3.6.5, pytest-3.4.2, py-1.5.3, pluggy-0.6.0 -- /usr/local/bin/python3.6
cachedir: .pytest_cache
rootdir: /usr/home/ericbsd/projects/freenas/freenas/tests, inifile:
collected 10 items                                                                                                           

api2/system_general.py::test_01_get_system_general PASSED                                                              [ 10%]
api2/system_general.py::test_02_get_system_general_language_choices PASSED                                             [ 20%]
api2/system_general.py::test_03_get_system_general_timezone_choices PASSED                                             [ 30%]
api2/system_general.py::test_04_get_system_general_country_choices PASSED                                              [ 40%]
api2/system_general.py::test_05_get_system_general_kbdmap_choices PASSED                                               [ 50%]
api2/system_general.py::test_06_Setting_timezone PASSED                                                                [ 60%]
api2/system_general.py::test_07_Checking_timezone_using_api PASSED                                                     [ 70%]
api2/system_general.py::test_08_Checking_timezone_using_ssh PASSED                                                     [ 80%]
api2/system_general.py::test_09_Setting_sysloglevel PASSED                                                             [ 90%]
api2/system_general.py::test_10_Checking_sysloglevel_using_api PASSED                                                  [100%]

-------- generated xml file: /usr/home/ericbsd/projects/freenas/freenas/tests/results/system_general_tests_result.xml --------
================================================= 10 passed in 7.64 seconds ==================================================

#7 Updated by Dru Lavigne over 1 year ago

  • Status changed from Ready for Testing to Done

Also available in: Atom PDF