From b81a7b0071bbbee4cf29d5016ff4cbfd2ddb82e1 Mon Sep 17 00:00:00 2001 From: Brian DeHamer Date: Mon, 25 Nov 2024 11:23:26 -0800 Subject: [PATCH] Fix body encoding in mock Rekor server Co-authored-by: Samuel Giddins Signed-off-by: Brian DeHamer --- .changeset/thin-garlics-reflect.md | 5 +++++ packages/mock/src/rekor/tlog.test.ts | 1 + packages/mock/src/rekor/tlog.ts | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/thin-garlics-reflect.md diff --git a/.changeset/thin-garlics-reflect.md b/.changeset/thin-garlics-reflect.md new file mode 100644 index 00000000..163a2081 --- /dev/null +++ b/.changeset/thin-garlics-reflect.md @@ -0,0 +1,5 @@ +--- +'@sigstore/mock': patch +--- + +Fix encoding of body field returned by mock Rekor server diff --git a/packages/mock/src/rekor/tlog.test.ts b/packages/mock/src/rekor/tlog.test.ts index 00b503a7..9c06802a 100644 --- a/packages/mock/src/rekor/tlog.test.ts +++ b/packages/mock/src/rekor/tlog.test.ts @@ -47,6 +47,7 @@ describe('TLog', () => { const entry = result[uuid]; expect(entry.body).toBeDefined(); + expect(typeof entry.body).toBe('string'); expect(JSON.parse(Buffer.from(entry.body, 'base64').toString())).toEqual( proposedEntry ); diff --git a/packages/mock/src/rekor/tlog.ts b/packages/mock/src/rekor/tlog.ts index b944984b..c730bce7 100644 --- a/packages/mock/src/rekor/tlog.ts +++ b/packages/mock/src/rekor/tlog.ts @@ -13,7 +13,7 @@ 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. */ - + import { LogEntry } from '@sigstore/rekor-types'; import canonicalize from 'canonicalize'; import crypto from 'crypto'; @@ -70,7 +70,7 @@ class TLogImpl implements TLog { return { [uuid]: { - body: body, + body: body.toString('base64'), integratedTime: timestamp, logID: logID.toString('hex'), logIndex: logIndex,