From 6901769e9bdddc11bf04bd3a33a5859aa2ab8289 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Wed, 12 Jul 2023 14:37:07 -0400 Subject: [PATCH] test: invariant preservation test Signed-off-by: William Woodruff --- test/unit/test_transparency.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/unit/test_transparency.py diff --git a/test/unit/test_transparency.py b/test/unit/test_transparency.py new file mode 100644 index 00000000..f15e4164 --- /dev/null +++ b/test/unit/test_transparency.py @@ -0,0 +1,33 @@ +# Copyright 2022 The Sigstore Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from base64 import b64encode +import pytest +from sigstore.transparency import LogEntry + + +class TestLogEntry: + def test_consistency(self): + with pytest.raises( + ValueError, match=r"Log entry must have either inclusion proof or promise" + ): + LogEntry( + uuid="fake", + body=b64encode("fake".encode()), + integrated_time=0, + log_id="1234", + log_index=1, + inclusion_proof=None, + inclusion_promise=None, + )