Commit Graph

20 Commits (65a943d8929c578041f789665b05810ea68986cb)

Author SHA1 Message Date
Michael Chisholm 15316e7933 Added "x-" to SCO extension names in unit tests, to illustrate
best practice and follow a spec "should" rule.
2020-03-12 16:20:32 -04:00
Michael Chisholm d708537b85 Add enforcement of a new STIX 2.1 SCO extension name requirement:
that it must end with "-ext".
2020-03-10 20:24:53 -04:00
Desai, Kartikey H 055ad97a7a Add tests for _id_contributing_properties for custom observables 2020-02-27 15:15:37 -05:00
Desai, Kartikey H f09cf4867d Remove unnecessary comments 2019-12-06 09:35:36 -05:00
Desai, Kartikey H 3a46d42aaa parse() handles observables in 2.1. Change mechanism for (in)valid_types in ReferenceProperty. Fix _custom_observable_builder to include ReferenceProperty instead of ObjectReferenceProperty, and added ID property to custom observables 2019-12-06 09:35:36 -05:00
Michael Chisholm 94bb76f669 Fix docstring on the unit tests I added. I'd said "partially
cleaned" property, but actually, the cleaning algorithm works on
a dict copy, so aborting cleaning partway through doesn't
actually affect the object in that way.  It would actually cause
the extensions property to be completely uncleaned, rather than
partially cleaned.
2019-08-26 17:49:55 -04:00
Michael Chisholm c212c7c678 Fix handling of custom extensions: make sure when
allow_custom=True that you never get a half-cleaned property
value.
2019-08-26 17:10:54 -04:00
Michael Chisholm 5589480980 Improved the exception class hierarchy:
- Removed all plain python base classes (e.g. ValueError, TypeError)
- Renamed InvalidPropertyConfigurationError -> PropertyPresenceError,
  since incorrect values could be considered a property config error, and
  I really just wanted this class to apply to presence (co-)constraint
  violations.
- Added ObjectConfigurationError as a superclass of InvalidValueError,
  PropertyPresenceError, and any other exception that could be raised
  during _STIXBase object init, which is when the spec compliance
  checks happen.  This class is intended to represent general spec
  violations.
- Did some class reordering in exceptions.py, so all the
  ObjectConfigurationError subclasses were together.

Changed how property "cleaning" errors were handled:
- Previous docs said they should all be ValueErrors, but that would require
  extra exception check-and-replace complexity in the property
  implementations, so that requirement is removed.  Doc is changed to just
  say that cleaning problems should cause exceptions to be raised.
  _STIXBase._check_property() now handles most exception types, not just
  ValueError.
- Decided to try chaining the original clean error to the InvalidValueError,
  in case the extra diagnostics would be helpful in the future.  This is
  done via 'six' adapter function and only works on python3.
- A small amount of testing was removed, since it was looking at custom
  exception properties which became unavailable once the exception was
  replaced with InvalidValueError.

Did another pass through unit tests to fix breakage caused by the changed
exception class hierarchy.

Removed unnecessary observable extension handling code from
parse_observable(), since it was all duplicated in ExtensionsProperty.
The redundant code in parse_observable() had different exception behavior
than ExtensionsProperty, which makes the API inconsistent and unit tests
more complicated.  (Problems in ExtensionsProperty get replaced with
InvalidValueError, but extensions problems handled directly in
parse_observable() don't get the same replacement, and so the exception
type is different.)

Redid the workbench monkeypatching.  The old way was impossible to make
work, and had caused ugly ripple effect hackage in other parts of the
codebase.  Now, it replaces the global object maps with factory functions
which behave the same way when called, as real classes.  Had to fix up a
few unit tests to get them all passing with this monkeypatching in place.
Also remove all the xfail markings in the workbench test suite, since all
tests now pass.

Since workbench monkeypatching isn't currently affecting any unit tests,
tox.ini was simplified to remove the special-casing for running the
workbench tests.

Removed the v20 workbench test suite, since the workbench currently only
works with the latest stix object version.
2019-07-19 14:50:11 -04:00
Desai, Kartikey H cdac66c04d Update v21 test suite. Fixes #245 2019-01-23 10:56:20 -05:00
Emmanuelle Vargas-Gonzalez 1b0fa0129f pre-commit changes 2018-11-29 11:06:27 -05:00
Emmanuelle Vargas-Gonzalez aaddeb8b97 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into 1.1.0-release 2018-11-28 11:21:27 -05:00
Emmanuelle Vargas-Gonzalez acd86c80dd Update tests to new object constraints 2018-10-15 14:48:52 -04:00
Emmanuelle Vargas-Gonzalez 51a499cb33 Formatting changes made by the new pre-commit hook 'add trailing commas'
closes #189
2018-07-13 11:10:05 -04:00
Emmanuelle Vargas-Gonzalez 281dbfb0f4 Align tests with news additions from 'master' branch. 2018-07-11 09:43:37 -04:00
Emmanuelle Vargas-Gonzalez ce42c02cee Fix tests that use property objects to call in the right path 2018-07-10 15:56:22 -04:00
Emmanuelle Vargas-Gonzalez 0197f9fd17 Minor fixes to tests. Some datastore had strange parameters in calls.
Fix error values for CustomMarking and fix incorrect test data
2018-07-09 15:20:04 -04:00
Emmanuelle Vargas-Gonzalez 21d5451d1c Small changes to tests 2018-07-06 14:11:59 -04:00
Emmanuelle Vargas-Gonzalez 2c5ddc14af Update v21 tests for some missing methods, ensure we are calling and
using the right classes.
2018-07-05 15:21:09 -04:00
Emmanuelle Vargas-Gonzalez 04680d8a3d First pass at making sure everything uses v21 classes and representations 2018-07-03 09:40:51 -04:00
Emmanuelle Vargas-Gonzalez da5b16dc2f Create v21 test package with new spec changes 2018-07-03 07:00:18 -04:00