Project

General

Profile

Bug #35167

Properly report invalid cloud credentials

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

Status:
Done
Priority:
No priority
Assignee:
Vladimir Vinogradenko
Category:
Middleware
Target version:
Severity:
Low 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

the code is at https://github.com/freenas/freenas/blob/master/tests/api2/backup.py

I did create a test to post I am not sure it is right here is the pytest output.

sudo pytest-3.6 -v api2/backup.py
==================================================== 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 4 items                                                                                                            

api2/backup.py::test_01_check_backup PASSED                                                                            [ 25%]
api2/backup.py::test_02_creating_dataset_backup PASSED                                                                 [ 50%]
api2/backup.py::test_03_creating_backup_backup FAILED                                                                  [ 75%]
api2/backup.py::test_02_destroying_backup_dataset PASSED                                                               [100%]

========================================================== FAILURES ==========================================================
_______________________________________________ test_03_creating_backup_backup _______________________________________________

    def test_03_creating_backup_backup():
        payload = {"description": "Test backup",
                   "direction": "PULL",
                   "transfer_mode": "COPY",
                   "path": "/mnt/tank/backup",
                   "credential": 0,
                   "minute": "1",
                   "hour": "0",
                   "daymonth": "0",
                   "dayweek": "0",
                   "month": "0",
                   "enabled": True}
        results = POST("/backup/", payload)
>       assert results.status_code == 200, results.text
E       AssertionError: <h1>500 Internal Server Error</h1><br><h2>Traceback:</h2>
E         &lt;pre&gt;Traceback (most recent call last):
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py&amp;quot;, line 381, in start
E             resp = await self._request_handler(request)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/aiohttp/web_app.py&amp;quot;, line 322, in _handle
E             resp = await handler(request)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/aiohttp/web_middlewares.py&amp;quot;, line 88, in impl
E             return await handler(request)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/aiohttp/web_middlewares.py&amp;quot;, line 78, in impl
E             return await handler(request)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/restful.py&amp;quot;, line 365, in on_method
E             return await do(method, req, resp, *args, **kwargs)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/restful.py&amp;quot;, line 497, in do
E             result = await self.middleware.call(methodname, *method_args)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/main.py&amp;quot;, line 1017, in call
E             return await self._call(name, serviceobj, methodobj, params, pipes=pipes)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/main.py&amp;quot;, line 953, in _call
E             return await methodobj(*args)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/service.py&amp;quot;, line 277, in create
E             f&amp;#x27;{self._config.namespace}.create&amp;#x27;, self, self.do_create, [data]
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/main.py&amp;quot;, line 953, in _call
E             return await methodobj(*args)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/schema.py&amp;quot;, line 646, in nf
E             return await f(*args, **kwargs)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/plugins/backup.py&amp;quot;, line 172, in do_create
E             return (await self.middleware.call(&amp;quot;cloudsync.create&amp;quot;, backup))[&amp;quot;id&amp;quot;]
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/main.py&amp;quot;, line 1017, in call
E             return await self._call(name, serviceobj, methodobj, params, pipes=pipes)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/main.py&amp;quot;, line 953, in _call
E             return await methodobj(*args)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/service.py&amp;quot;, line 277, in create
E             f&amp;#x27;{self._config.namespace}.create&amp;#x27;, self, self.do_create, [data]
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/main.py&amp;quot;, line 953, in _call
E             return await methodobj(*args)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/schema.py&amp;quot;, line 646, in nf
E             return await f(*args, **kwargs)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/plugins/cloud_sync.py&amp;quot;, line 364, in do_create
E             await self._validate(verrors, &amp;quot;cloud_sync&amp;quot;, cloud_sync)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/plugins/cloud_sync.py&amp;quot;, line 265, in _validate
E             credentials = await self._get_credentials(data[&amp;quot;credentials&amp;quot;])
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/plugins/cloud_sync.py&amp;quot;, line 257, in _get_credentials
E             {&amp;quot;get&amp;quot;: True})
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/main.py&amp;quot;, line 1017, in call
E             return await self._call(name, serviceobj, methodobj, params, pipes=pipes)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/main.py&amp;quot;, line 953, in _call
E             return await methodobj(*args)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/schema.py&amp;quot;, line 646, in nf
E             return await f(*args, **kwargs)
E           File &amp;quot;/usr/local/lib/python3.6/asyncio/coroutines.py&amp;quot;, line 110, in __next__
E             return self.gen.send(None)
E           File &amp;quot;/usr/local/lib/python3.6/site-packages/middlewared/plugins/datastore.py&amp;quot;, line 177, in query
E             return result[0]
E         IndexError: list index out of range
E         &lt;/pre&gt;
E       assert 500 == 200
E        +  where 500 = &lt;Response [500]&gt;.status_code

api2/backup.py:42: AssertionError
============================================= 1 failed, 3 passed in 0.96 seconds =============================================

Associated revisions

Revision ec774b00 (diff)
Added by Vladimir Vinogradenko about 1 year ago

fix(cloud_sync): Properly report invalid credentials

Ticket: #35167

Revision 2949c904 (diff)
Added by Vladimir Vinogradenko about 1 year ago

fix(cloud_sync): Properly report invalid credentials

Ticket: #35167

History

#1 Updated by Dru Lavigne about 1 year ago

  • Assignee changed from Release Council to William Grzybowski

#2 Updated by Vladimir Vinogradenko about 1 year ago

Fixed. Now you should receive proper error.

#3 Updated by Dru Lavigne about 1 year ago

  • Subject changed from REST API 2.0 POST backup problem to Properly report invalid cloud credentials
  • Target version changed from Backlog to 11.2-BETA1
  • Needs Doc changed from Yes to No
  • Needs Merging changed from Yes to No

#4 Updated by William Grzybowski about 1 year ago

  • Status changed from Unscreened to Ready for Testing
  • Assignee changed from William Grzybowski to Vladimir Vinogradenko

#5 Updated by William Grzybowski about 1 year ago

  • Severity changed from New to Low Medium

#6 Updated by Eric Turgeon about 1 year ago

  • Needs QA changed from Yes to No

This is fix

#7 Updated by Dru Lavigne about 1 year ago

  • Status changed from Ready for Testing to Done

Also available in: Atom PDF