uses id of public key in overview

This commit is contained in:
Sebastian Sdorra
2020-07-30 13:27:40 +02:00
parent 103edf2356
commit 2763e6eccf
5 changed files with 3 additions and 68 deletions

View File

@@ -51,7 +51,7 @@ export const PublicKeyEntry: FC<Props> = ({ publicKey, onDelete }) => {
<td>
<DateFromNow date={publicKey.created} />
</td>
<td className="is-hidden-mobile">{formatPublicKey(publicKey.raw)}</td>
<td className="is-hidden-mobile">{publicKey.id}</td>
<td>{deleteButton}</td>
</tr>
</>

View File

@@ -35,6 +35,7 @@ export type PublicKeysCollection = Collection & {
};
export type PublicKey = {
id: string;
displayName: string;
raw: string;
created?: string;

View File

@@ -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 ");
});
});

View File

@@ -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);
};

View File

@@ -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;