From 2763e6eccf6326a4a1484fc700b1ef07c1626ad1 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 30 Jul 2020 13:27:40 +0200 Subject: [PATCH] uses id of public key in overview --- .../components/publicKeys/PublicKeyEntry.tsx | 2 +- .../components/publicKeys/SetPublicKeys.tsx | 1 + .../publicKeys/formatPublicKey.test.ts | 36 ------------------- .../components/publicKeys/formatPublicKey.ts | 31 ---------------- .../sonia/scm/security/gpg/RawGpgKeyDto.java | 1 + 5 files changed, 3 insertions(+), 68 deletions(-) delete mode 100644 scm-ui/ui-webapp/src/users/components/publicKeys/formatPublicKey.test.ts delete mode 100644 scm-ui/ui-webapp/src/users/components/publicKeys/formatPublicKey.ts diff --git a/scm-ui/ui-webapp/src/users/components/publicKeys/PublicKeyEntry.tsx b/scm-ui/ui-webapp/src/users/components/publicKeys/PublicKeyEntry.tsx index 88c1dfe19e..cea7514ab3 100644 --- a/scm-ui/ui-webapp/src/users/components/publicKeys/PublicKeyEntry.tsx +++ b/scm-ui/ui-webapp/src/users/components/publicKeys/PublicKeyEntry.tsx @@ -51,7 +51,7 @@ export const PublicKeyEntry: FC = ({ publicKey, onDelete }) => { - {formatPublicKey(publicKey.raw)} + {publicKey.id} {deleteButton} diff --git a/scm-ui/ui-webapp/src/users/components/publicKeys/SetPublicKeys.tsx b/scm-ui/ui-webapp/src/users/components/publicKeys/SetPublicKeys.tsx index a3c141d35a..c975a83533 100644 --- a/scm-ui/ui-webapp/src/users/components/publicKeys/SetPublicKeys.tsx +++ b/scm-ui/ui-webapp/src/users/components/publicKeys/SetPublicKeys.tsx @@ -35,6 +35,7 @@ export type PublicKeysCollection = Collection & { }; export type PublicKey = { + id: string; displayName: string; raw: string; created?: string; diff --git a/scm-ui/ui-webapp/src/users/components/publicKeys/formatPublicKey.test.ts b/scm-ui/ui-webapp/src/users/components/publicKeys/formatPublicKey.test.ts deleted file mode 100644 index ddc1ba076b..0000000000 --- a/scm-ui/ui-webapp/src/users/components/publicKeys/formatPublicKey.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2020-present Cloudogu GmbH and Contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { formatPublicKey } from "./formatPublicKey"; - -describe("format public key tests", () => { - it("should format the given key", () => { - const key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nA1B2C3D4E5F6HDJSURNSKFHSNEKFHK443MKD\n-----END PGP PUBLIC KEY BLOCK-----"; - expect(formatPublicKey(key)).toEqual("A1B2C3D4E5F6HDJ"); - }); - - it("should format bad formatted key", () => { - const key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\n\nA1B2C3D4E5F6HDJSURNSKFHSNEKFHK443MKD\n\n\n-----END PGP PUBLIC KEY BLOCK-----"; - expect(formatPublicKey(key)).toEqual("-----BEGIN PGP "); - }); -}); diff --git a/scm-ui/ui-webapp/src/users/components/publicKeys/formatPublicKey.ts b/scm-ui/ui-webapp/src/users/components/publicKeys/formatPublicKey.ts deleted file mode 100644 index 322ebb88e8..0000000000 --- a/scm-ui/ui-webapp/src/users/components/publicKeys/formatPublicKey.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2020-present Cloudogu GmbH and Contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -export const formatPublicKey = (key: string) => { - const parts = key.split(/\n/); - if (parts[2].length >= 15) { - return parts[2].substring(0, 15); - } - return parts[0].substring(0, 15); -}; diff --git a/scm-webapp/src/main/java/sonia/scm/security/gpg/RawGpgKeyDto.java b/scm-webapp/src/main/java/sonia/scm/security/gpg/RawGpgKeyDto.java index 2e40555e42..b56df8f726 100644 --- a/scm-webapp/src/main/java/sonia/scm/security/gpg/RawGpgKeyDto.java +++ b/scm-webapp/src/main/java/sonia/scm/security/gpg/RawGpgKeyDto.java @@ -38,6 +38,7 @@ import java.time.Instant; @SuppressWarnings("squid:S2160") // we do not need equals for dto public class RawGpgKeyDto extends HalRepresentation { + private String id; private String displayName; private String raw; private Instant created;