Commit Graph

414 Commits

Author SHA1 Message Date
justin-h-loi 400c29bc4f Removing bandit/pyaml version requirements 2023-08-29 16:33:43 -04:00
justin-h-loi 483fc6c57f alternate config unit test fix 2023-08-29 16:33:43 -04:00
arp102 0b63de97ee Fix test_mac_with_cryptographic_failure unit test.
This test is meant to intentionally trigger an exception in the cryptography library
by creating a CMAC with a non-block cipher algorithm, IDEA.
That doesn't work any more because IDEA is now treated as a block cipher algorithm.
To fix this, we now use the ARC4 algorithm instead,
which does trigger the expected exception.
2023-08-11 18:36:27 -04:00
Konstantin Trushin 263cb34662 Fix source code style to comply with PEP8 2023-03-27 11:16:46 -04:00
Grace Lombardi 0a3e39143f Updated app specific info to be a list of dictionaries, removed unneeded sudo in run.sh, updated server.conf to remove db, updated tests and comments to reflect app specific info being a list 2022-07-25 10:12:56 -04:00
Grace Lombardi 124f7db5cb Updated test for App Specific Info for Symmetric Key and added test for App Specific Info for SecretData 2022-07-25 10:12:56 -04:00
Grace Lombardi 1773fba67c Updated client integration tests, Added test for Application Specific Information 2022-07-25 10:12:56 -04:00
Karthikeyan Singaravelan b38b805bf0 Use assertEqual instead of assertEquals for Python 3.11 compatibility. 2022-03-16 14:14:33 -04:00
Tim Burke c0c9803956 Fix tests to pass with SQLAlchemy>=1.4.0
I'm not *entirely* sure what's going on here, but it seems that when we
do something like

    obj = OpaqueObject(...)
    Session = sessionmaker(...)
    session = Session()
    ...
    session.add(obj)
    session.commit()

the primary key (and maybe some foreign relations?) aren't automatically
populated on `obj` following the commit, and will attempt to lazy-load
on next reference. Since expire_on_commit defaults to True, the session
attached to `obj` (which is no longer the `session` in locals!) is closed
out when we later do

    session = Session()
    get_obj = session.query(OpaqueObject).filter(
        ManagedObject.unique_identifier == obj.unique_identifier).one()

leading to a DetachedInstanceError.

There seem to be a few different ways we can fix this:

* Set expire_on_commit=False so the old session is still useful for the
  lazy-loading.
* Re-use the same session instead of creating a new one.
* Explicitly refresh added objects post-commit.

Generally prefer the first one; there's some prior art to follow in
services/server/test_engine.py. Curiously, that same file runs into
trouble despite already setting expire_on_commit=False -- so do the
explicit refresh, on the assumption that there was a reason we went to
the trouble of creating a fresh session.

Closes #649
2021-09-23 13:43:04 -04:00
Peter Hamilton ae05118804 Add integration tests for the Modify and DeleteAttribute operations
This change adds integration tests for the client and server for
the Modify and DeleteAttribute operations, proving they work in
tandem. Minor bug fixes in the client are included to enable
correct test execution.

Partially implements #547
2019-12-13 16:21:32 -05:00
Peter Hamilton cd8d66fe91 Fix a bug with attribute index handling in ModifyAttribute
This changes fixes a minor bug with proper attribute index range
checking in the server implementation of ModifyAttribute. A corner
case that previously slipped through index checking and testing
has been closed. An existing unit test has been modified to fix
this bug.

Partially implements #547
2019-12-13 15:42:20 -05:00
Peter Hamilton 48350a4166 Update the payload factories to support new attribute operations
This change updates the request and response payload factories to
add support for the Set, Modify, and DeleteAttribute payloads.
Unit tests have been added to cover the changes.

Partially implements #547
2019-12-13 13:08:44 -05:00
Peter Hamilton 4e59a8a1f0 Add ModifyAttribute support to the server
This change adds ModifyAttribute operation support to the PyKMIP
server, including additional attribute policy functionality to
check for certain attribute characteristics that preclude
ModifyAttribute operation functionality. New unit tests have been
added to cover these changes.

Partially implements #547
2019-12-09 10:27:51 -05:00
Peter Hamilton 53308c346b Add ModifyAttribute support to the client
This change adds ModifyAttribute support to the ProxyKmipClient,
leveraging the new generic request capability in the underlying
KMIPProxy client. New unit tests have been added to cover the new
client additions.

Partially implements #547
2019-11-27 14:57:47 -05:00
Peter Hamilton 2d283e128c Add SetAttribute support to the client
This change adds SetAttribute support to the ProxyKmipClient,
leveraging the new generic request capability in the underlying
KMIPProxy client. New unit tests have been added to cover the new
client additions.

Partially implements #547
2019-11-22 18:01:23 -05:00
Peter Hamilton 3be219144a Add SetAttribute support to the server
This change adds SetAttribute operation support to the PyKMIP
server, including additional attribute policy functionality to
check for certain attribute characteristics that preclude
SetAttribute operation functionality. Specifically, the operation
cannot set the value of any multivalued attribute nor the value
of any attribute not modifiable by the client. New unit tests
have been added to cover these changes.

Partially implements #547
2019-11-22 16:29:51 -05:00
Peter Hamilton e313731692 Add support for the Sensitive attribute
This change adds support for the Sensitive attribute, adding it to
the attribute factory, the SQLAlchemy object hierarchy, and to the
server attribute handling methods. The intent is to use this new
attribute to test the new SetAttribute and ModifyAttribute
operations coming in future commits. Unit tests have been added
and modified to support the new additions.
2019-11-22 15:08:37 -05:00
Peter Hamilton 4d2d2ba4f1 Add the ModifyAttribute request and response payloads
This change adds support for the ModifyAttribute operation in the
form of request and response payload structures. These will be used
in future updates to the client and server to fully support the
ModifyAttribute operation. A new unit test suite has been added to
cover the new changes.

Partially Implements #547
2019-11-21 12:39:28 -05:00
Peter Hamilton 1bb314d523 Add the SetAttribute request and response payloads
This change adds support for the SetAttribute operation in the
form of request and response payload structures. These will be used
in future updates to the client and server to fully support the
SetAttribute operation. A new unit test suite has been added to
cover the new changes.

Partially Implements #547
2019-11-20 09:41:10 -05:00
Peter Hamilton 072d55a9c3 Add support for the NewAttribute structure
This change adds support for the NewAttribute structure added
in KMIP 2.0. The NewAttribute structure is a basic container
structure that contains a single attribute instance for use by
attribute operations. A new unit test suite has been added to cover
the new additions.

Partially implements #547
2019-11-18 10:12:33 -05:00
Peter Hamilton b045e08ce2 Add DeleteAttribute support to the client
This change adds DeleteAttribute support to the ProxyKmipClient,
leveraging the new generic request capability in the underlying
KMIPProxy client. Going forward all new attribute support will
leverage the new request capability and older supported operations
will be migrated to use it as well, with the ultimate vision
being a final merger of the two client classes into one easy to
use architecture. New unit tests have been added to cover the new
client additions.

Partially implements #547
2019-11-15 17:01:21 -05:00
Peter Hamilton 676aaf5e72 Add DeleteAttribute support to the server
This change adds DeleteAttribute operation support to the PyKMIP
server, supporting functionality unique to KMIP 1.0 - 1.4 and the
newer KMIP 2.0. Due to the current list of attributes supported
by the server, only multivalued attributes can currently be
deleted from a stored KMIP object. Over a dozen unit tests have
been added to verify the functionality of the new additions.

Partially implements #547
2019-11-08 18:36:03 -05:00
Peter Hamilton e48aff7b9a Add the DeleteAttribute request and response payloads
This change adds support for the DeleteAttribute operation in the
form of request and response payload structures. These will be used
in a future updates by the client and server to fully support the
DeleteAttribute operation. A new unit test suite has been added to
cover the new changes.

Partially implements #547
2019-11-01 17:41:56 -04:00
Peter Hamilton 616e683370 Add support for the CurrentAttribute structure
This change adds support for the CurrentAttribute structure added
in KMIP 2.0. The CurrentAttribute structure is a basic container
structure that contains a single attribute instance for use by
attribute operations. A new unit test suite has been added to cover
the new additions.

Partially implements #547
2019-11-01 08:32:49 -04:00
Peter Hamilton cd1079afd5 Add integration tests for Locate using new attributes
This change adds integration tests that verify that objects can
be found by Locate when filtering off of the new ObjectGroup and
ApplicationSpecificInformation attributes. Some minor tweaks to
the database attribute models are included to simplify usage.
2019-10-11 16:45:50 -04:00
Peter Hamilton 009e8cecc9 Add ObjectGroup support to the server
This change ObjectGroup attribute support to the server, allowing
for the storage and retrieval of the new attribute in addition to
object filtering based on its value. New unit tests have been
added to cover the new changes.
2019-10-11 09:58:10 -04:00
Peter Hamilton 1b81fff431 Add ObjectGroup to the database model
This change adds a new SQLAlchemy object to the database model
representing the ObjectGroup attribute. The new object is linked
to the base ManagedObject object, allowing ObjectGroup attributes
to be associated with any managed object. A new unit test suite
has been added to verify the new object functionality and to
confirm that the object can be stored and retrieved from an
in-memory database.
2019-10-10 16:33:39 -04:00
Peter Hamilton 89e9b22c34 Update how the ObjectGroup attribute is defined and used
This change updates the attribute factory, replacing the custom
ObjectGroup class with the proper usage of the TextString
primitive. ObjectGroup attribute usage and testing has been
updated across the library to reflect this change.
2019-10-07 13:52:17 -04:00
Peter Hamilton 01eb144243 Add ApplicationSpecificInformation support to the server
This change adds ApplicationSpecificInformation attribute support
to the server, allowing for the storage and retrieval of the new
attribute in addition to object filtering based on its value. New
unit tests have been added to cover the new changes.
2019-10-03 17:00:05 -04:00
Peter Hamilton 3f84a20a0c Add ApplicationSpecificInformation to the database model
This change adds a new SQLAlchemy object to the database model
representing the ApplicationSpecificInformation attribute. The
new object is linked to the base ManagedObject object, allowing
ApplicationSpecificInformation attributes to be associated with
any managed object. This also represents how KMIP attributes
should be supported going forward. A new unit test suite has
been added to verify the new object functionality and to confirm
that the object can be stored and retrieved from an in-memory
database.
2019-09-30 12:32:10 -04:00
Peter Hamilton b7d2cc1382 Update ApplicationSpecificInformation support to modern style
This change updates the ApplicationSpecificInformation attribute
implementation to reflect modern library style. Property methods
have been added alongside tighter read/write error checking. The
unit tests for the attribute have been updated to reflect all of
the new changes.
2019-09-27 11:15:33 -04:00
Peter Hamilton 29750cbda6 Add SplitKey server integration tests
This change adds integration tests that test registering,
retrieving, and destroying SplitKey objects with the server.
Minor updates are included for the client and server to ensure
that SplitKey operations function as expected.

Partially implements #545
2019-09-20 14:04:57 -04:00
Peter Hamilton a8713fc909 Add conversion utilities for SplitKey objects
This change adds conversion utilities for SplitKey objects,
allowing for conversions between the Pie and Core object spaces.
The server is also updated to recognize the new Pie SplitKey
object. Unit tests have been added and tweaked to accommodate
these changes.

Partially implements #545
2019-09-20 11:11:26 -04:00
Peter Hamilton 84ab77cd8d Add SQLAlchemy-based SplitKey support
This change adds a SQLAlchemy-based implementation of the SplitKey
object that will be used by the ProxyKmipClient and PyKMIP server
to store SplitKeys. A new unit test suite is included that checks
object fields and verifies it can be persisted to and retrieved
from an in-memory SQLAlchemy-managed database.

Partially implements #545
2019-09-13 16:35:49 -04:00
Peter Hamilton 64d78dc8e3 Update encoding support for SplitKey objects
This change updates encoding support for SplitKey objects, bringing
it up-to-date with the modern conventions used in the rest of the
library. A new unit test suite has been added to cover the new
functionality.

Partially implements #545
2019-09-11 09:26:06 -04:00
Peter Hamilton c1b816bf04 Fix a bug with how key pair names are handled in the client
This change fixes a bug with how key pair names are handled by the
ProxyKmipClient. The original implementation stored key pair names
in the 'names' field of the various template attributes used to
define the key pair attributes. However, the 'names' field is
meant for the names of existing template objects that should be
used as another source for attribute values. Before KMIP 2.0
support was added, this worked because attributes and names were
encoded the same way and were interpreted by the server correctly.
The addition of KMIP 2.0 drops the 'names' field when handling
template attributes, dropping the names from being sent to the
server when creating new key pairs. This change fixes this and
updates relevant client unit tests to detect this error in the
future.

Fixes #560
2019-08-23 17:22:27 -04:00
oleksiys 16480bc9a2 Address PR comment 2019-08-21 08:32:45 -04:00
oleksiys c2bfd3e835 + Strip the tag to the requested tag_length.
+ Add GCM test.
2019-08-21 08:32:45 -04:00
oleksiys ead6c431bc Address PR comments 2019-08-21 08:32:45 -04:00
oleksiys 26c1c71fff Add support for AES GCM mode. 2019-08-21 08:32:45 -04:00
Peter Hamilton 44d55f2550 Add CertificateType filtering support for Locate
This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects based on the object's
Certificate Type. Unit tests and integration tests have
been added to test and verify the correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support Certificate Type filtering. Simply use the
"--certificate-type" flag to specify a Certificate Type
enumeration values for the Locate script to filter on.
2019-08-16 17:31:42 -04:00
Peter Hamilton b5a8739157 Add CryptographicUsageMask filtering support for Locate
This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects based on the object's
Cryptographic Usage Masks. Unit tests and integration tests have
been added to test and verify the correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support Cryptographic Usage Mask filtering. Simply use the
"--cryptographic-usage-mask" flag to specify one or more
Cryptographic Usage Mask enumeration values for the Locate script
to filter on.
2019-08-12 16:54:03 -04:00
Peter Hamilton 4a6a2eccc1 Add offset and maximum item filtering for the Locate operation
This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects using the offset and maximum item
constraints. The offset constraint tells the server how many
matching items should be skipped before results are returned. The
maximum items constraint tells the server how many matching items
should be returned. Unit tests and integration tests have been
added to test and verify the correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support offset and maximum item filtering. Simply use the
"--offset-items" and "--maximum-items" flags to specify offset and
maximum item values for the Locate script to filter on.

Fixes #562
2019-08-09 17:13:20 -04:00
Peter Hamilton c3c03e5091 Fix a bug with the debug logging for Initial Date filtering
This change fixes a bug in the server engine unit tests that
check the debug logs for Locate filtering on the Initial Date
attribute. Specifically, time.asctime does not use the default
'%d' notation for stringifying numerical day values. This change
updates the string notation to match the format produced by
time.asctime.

Impacts #572
2019-08-09 11:04:42 -04:00
Peter Hamilton 942d55cca9 Add OperationPolicyName filtering support for Locate
This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects based on the object's Operation
Policy Name. Unit tests and integration tests have been added to
test and verify the correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support Operation Policy Name filtering. Simply use the
"--operation-policy-name" flag to specify an Operation Policy Name
string value for the Locate script to filter on.
2019-08-01 09:06:09 -04:00
Peter Hamilton 9e95d14e08 Add UniqueIdentifier filtering support for the Locate operation
This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects based on the object's Unique
Identifier. Unit tests and integration tests have been added to
test and verify the correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support Unique Identifier filtering. Simply use the
"--unique-identifier" flag to specify a Unique Identifier string
value for the Locate script to filter on.
2019-07-31 16:30:47 -04:00
Peter Hamilton 6dcae13c5b Add CryptographicLength filtering support for the Locate operation
This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects based on the object's
Cryptographic Length. If an object's type does not support the
Cryptographic Length attribute, the object is not a match. Unit
tests and integration tests have been added to test and verify
the correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support Cryptographic Length filtering. Simply use the
"--cryptographic-length" flag to specify a Cryptographic Length
integer value for the Locate script to filter on.
2019-07-31 13:12:43 -04:00
Peter Hamilton bf518c8393 Add CryptographicAlgorithm filtering support for Locate
This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects based on the object's
Cryptographic Algorithm. If an object's type does not support the
Cryptographic Algorithm attribute, that object is not a match.
Unit tests and integration tests have been added to test and
verify the correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support Cryptographic Algorithm filtering. Simply use the
"--cryptographic-algorithm" flag to specify a Cryptographic
Algorithm enumeration for the Locate script to filter on.
2019-07-31 09:41:48 -04:00
Peter Hamilton d74b394261 Add ObjectType filtering support for the Locate operation
This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects based on the object's Object Type.
Unit tests and integration tests have been added to test and verify
the correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support Object Type filtering. Simply use the "--object-type" flag
to specify an Object Type enumeration for the Locate script to
filter on.
2019-07-30 18:08:46 -04:00
Peter Hamilton e5de55c0a8 Add State filtering support for the Locate operation
This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects based on the object's State. Unit
tests and integration tests have been added to test and verify the
correctness of this feature.

Additionally, the Locate demo scripts have also been updated to
support State filtering. Simply use the "--state" flag to specify
a State enumeration for the Locate script to filter on.
2019-07-26 18:10:20 -04:00