This patch removes unused hacking M334 from HACKING.rst to avoid
confusing for new developers and also make the rule number in order.
Closes-Bug: #1539423
Change-Id: I79a791b39f7988254dd7fee1cb19dd16934475ae
When user is not authorized to perform operations defined in policy
file, it should return a 403 error. The 500 error is incorrect.
This patch do the following changes:
1. Raise a PolicyNotAuthorized 403 exception when normal user
without admin privilege run command 'magnum service-list'.
2. Remove unnecessary hacking rule M301 'decorator must be
the first decorator on a method'.
3. Fix failed enforcement test cases introduced by 403
PolicyNotAuthorized exception.
Change-Id: Ie5a7d138cdb8b226686c189ae86f251c0a1329c8
Closes-Bug: #1520311
PEP-0274 introduced dict comprehensions to replace dict constructor
with a sequence of length-2 sequences, these are benefits copied
from [1]:
The dictionary constructor approach has two distinct disadvantages
from the proposed syntax though. First, it isn't as legible as a
dict comprehension. Second, it forces the programmer to create an
in-core list object first, which could be expensive.
Magnum does not support python 2.6, we can leverage this.
There is deep dive about PEP-0274[2] and basic tests about
performance[3].
Note: This commit doesn't handle dict constructor with kwagrs.
This commit also adds a hacking rule.
[1]http://legacy.python.org/dev/peps/pep-0274/
[2]http://doughellmann.com/2012/11/12/the-performance-impact-of-using
-dict-instead-of-in-cpython-2-7-2.html
[3]http://paste.openstack.org/show/480757/
Change-Id: I61992fa428d6760449afe3754b02506336e8b421
Developer should use timeutils.utcnow to replace the
datetime.datetime.utcnow.
Change-Id: Ifaca72e286a805632cd17406464175ba6819a9b0
Closes-Bug: #1513308
Tests should use:
self.assertIn(value, list)
self.assertNotIn(value, list)
instead of:
self.assertTrue(value in list)
self.assertFalse(value in list)
because assertIn and assertNotIn raise more meaningful errors:
self.assertIn(3, [1, 2])
>>> MismatchError: 3 not in [1, 2]
self.assertTrue(3 in [1, 2])
>>> AssertionError: False is not true
Closes-Bug: #1510007
Change-Id: If33252cc93c06a85e61871fb7b22b726f4a08500
Developer should use assertIsInstance to replace the
assertTrue(isinstance(a, b)).
Closes-Bug: #1510384
Change-Id: I70f68a5810a6797c7b7e112b46ef2463907bba3e
Developer should use assertIsNotNone to replace the
assertEqual(** is not None).
Closes-Bug: #1510371
Change-Id: I5afd03aaf591e047b855bc416bc60fbc182bdc19
The usage of assertEqual(True/False, ***) should be changed to a more
meaningful format of assertTrue/False(***).
Closes-Bug: #1510001
Change-Id: Ia16af467d5f5bfca029002d9d261540947b0be92
Instead of using assertEqual(None, ***), developers should
use assertIsNone(***) to have more clear messages in case of failure.
Closes-Bug: #1510006
Change-Id: Ib3d09ed651877569a9b940da97662489885f18e9
Add doc8 to `tox -edocs` command. doc8 will check syntax/style check
rst documents and fail if not compliant.
Change-Id: Id2e9ed1f96cac27dc5e38f828fd2d824dad31c49
The best practice in Python is not to use mutable object (i.e. list,
dictionary, or instances of most classes) as value of default argument.
See: https://docs.python.org/2/tutorial/controlflow.html#default-argument-values
This patch also added a hacking rule to enforce this practice.
Change-Id: I4aa8aede57d6fd31b4b30c3f7535b819e591165d
Closes-Bug: 1471349
The hacking rule error code should be start with 'M', which stands for
Magnum.
PS: Error number begins with M301
Closes-Bug: #1465895
Change-Id: Ie9565c4a700a1bf85eed8c5db87a8c4012f5254b
This patch adds hacking rule check framework for magnum, and adds first rule:
policy.enforce_wsgi decorator must be the first decorator on a method.
refer this link for why we need this rule.
`https://review.openstack.org/#/c/190140/`
Closes-Bugs: #1465895
Change-Id: If98e47426b391b75755ca0b559aee1baa93b8503
These were the commits from github repo(s)
84d943e Initial commit
3d15bd1 Created the pecan project for containers for API
b49297b Added rest functionality to the v2 apis
227e1dd Added rest functionality to the v2 apis
39500ae Added the base API call like POST, GET, PUT & DELETE.
e404e94 adding wsme support to pecan
f90f540 Added wsme support to the magnum apis
c879329 added changes to api
24ebc32 Fixed the bugs in the container apis
01725ef Rename dir from containers to magnum
1a1375a Add requirements and test-requirements
f957e2e Add ASL2.0 license
8f4c0ee Move tests to the proper location
48dd100 Move setup files to proper directory
86cc435 Fix the setup so the installation is sanitary
b766d59 Make the installation and tox testing work
c477236 This is a new project - start with v1 for api
cf20cac Remove pep8 errors
d23b325 Merge with code generated using OpenStack cookie-cutter
b6b9f34 Ability to run pecan serve from command line
Had to update requirements.txt to get jobs working
Change-Id: I068389412d023c258bda40dfbdff5a40f2e7d175
Co-Authored-By: Digambar Patil <digambarpat@gmail.com>
Co-Authored-By: Steven Dake <sdake@redhat.com>