Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove: Removed the logic for the client certificates credential type. #3903

Merged
merged 8 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/gmp/models/__tests__/credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {setLocale} from 'gmp/locale/lang';
import Model from 'gmp/model';

import Credential, {
CLIENT_CERTIFICATE_CREDENTIAL_TYPE,
SNMP_CREDENTIAL_TYPE,
USERNAME_PASSWORD_CREDENTIAL_TYPE,
USERNAME_SSH_KEY_CREDENTIAL_TYPE,
Expand All @@ -47,15 +46,11 @@ const USERNAME_PASSWORD_CREDENTIAL = Credential.fromElement({
const USERNAME_SSH_KEY_CREDENTIAL = Credential.fromElement({
type: USERNAME_SSH_KEY_CREDENTIAL_TYPE,
});
const CLIENT_CERTIFICATE_CREDENTIAL = Credential.fromElement({
type: CLIENT_CERTIFICATE_CREDENTIAL_TYPE,
});
const SNMP_CREDENTIAL = Credential.fromElement({type: SNMP_CREDENTIAL_TYPE});
const PGP_CREDENTIAL = Credential.fromElement({type: PGP_CREDENTIAL_TYPE});
const SMIME_CREDENTIAL = Credential.fromElement({type: SMIME_CREDENTIAL_TYPE});

const createAllCredentials = () => [
CLIENT_CERTIFICATE_CREDENTIAL,
USERNAME_PASSWORD_CREDENTIAL,
USERNAME_SSH_KEY_CREDENTIAL,
SNMP_CREDENTIAL,
Expand Down Expand Up @@ -151,7 +146,6 @@ describe('Credential Model tests', () => {

describe('Credential model function tests', () => {
test('ssh_credential_filter should return filter with correct true/false', () => {
expect(ssh_credential_filter(CLIENT_CERTIFICATE_CREDENTIAL)).toEqual(false);
expect(ssh_credential_filter(USERNAME_SSH_KEY_CREDENTIAL)).toEqual(true);
expect(ssh_credential_filter(USERNAME_PASSWORD_CREDENTIAL)).toEqual(true);
});
Expand All @@ -167,9 +161,6 @@ describe('Credential model function tests', () => {
});

test('snmp_credential_filter should return filter with correct true/false', () => {
expect(snmp_credential_filter(CLIENT_CERTIFICATE_CREDENTIAL)).toEqual(
false,
);
expect(snmp_credential_filter(SNMP_CREDENTIAL)).toEqual(true);
});

Expand Down Expand Up @@ -231,9 +222,6 @@ describe('getCredentialTypeName tests', () => {
expect(getCredentialTypeName(USERNAME_SSH_KEY_CREDENTIAL_TYPE)).toEqual(
'Username + SSH Key',
);
expect(getCredentialTypeName(CLIENT_CERTIFICATE_CREDENTIAL_TYPE)).toEqual(
'Client Certificate',
);
expect(getCredentialTypeName(SNMP_CREDENTIAL_TYPE)).toEqual('SNMP');
expect(getCredentialTypeName(SMIME_CREDENTIAL_TYPE)).toEqual(
'S/MIME Certificate',
Expand Down
2 changes: 0 additions & 2 deletions src/gmp/models/credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {parseYesNo, NO_VALUE, parseDate} from 'gmp/parser';

export const USERNAME_PASSWORD_CREDENTIAL_TYPE = 'up';
export const USERNAME_SSH_KEY_CREDENTIAL_TYPE = 'usk';
export const CLIENT_CERTIFICATE_CREDENTIAL_TYPE = 'cc';
export const SNMP_CREDENTIAL_TYPE = 'snmp';
export const SMIME_CREDENTIAL_TYPE = 'smime';
export const PGP_CREDENTIAL_TYPE = 'pgp';
Expand Down Expand Up @@ -55,7 +54,6 @@ export const VFIRE_CREDENTIAL_TYPES = [USERNAME_PASSWORD_CREDENTIAL_TYPE];
export const ALL_CREDENTIAL_TYPES = [
USERNAME_PASSWORD_CREDENTIAL_TYPE,
USERNAME_SSH_KEY_CREDENTIAL_TYPE,
CLIENT_CERTIFICATE_CREDENTIAL_TYPE,
SNMP_CREDENTIAL_TYPE,
SMIME_CREDENTIAL_TYPE,
PGP_CREDENTIAL_TYPE,
Expand Down
71 changes: 18 additions & 53 deletions src/web/pages/credentials/__tests__/detailspage.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,68 +76,47 @@ const credential = Credential.fromElement({
allow_insecure: 1,
creation_time: '2020-12-16T15:23:59Z',
comment: 'blah',
formats: {format: 'pem'},
full_type: 'client certificate',
full_type: 'Username + SSH Key',
in_use: 0,
login: '',
modification_time: '2021-03-02T10:28:15Z',
name: 'credential 1',
owner: {name: 'admin'},
permissions: {permission: {name: 'Everything'}},
type: 'cc',
type: 'usk',
writable: 1,
certificate_info: {
activation_time: '2018-10-10T11:41:23.022Z',
expiration_time: '2019-10-10T11:41:23.022Z',
md5_fingerprint: 'asdf',
issuer: 'dn',
},
});

const noPermCredential = Credential.fromElement({
_id: '6575',
allow_insecure: 1,
creation_time: '2020-12-16T15:23:59Z',
comment: 'blah',
formats: {format: 'pem'},
full_type: 'client certificate',
full_type: 'Username + SSH Key',
in_use: 0,
login: '',
modification_time: '2021-03-02T10:28:15Z',
name: 'credential 1',
owner: {name: 'admin'},
permissions: {permission: {name: 'get_credentials'}},
type: 'cc',
type: 'usk',
writable: 1,
certificate_info: {
activation_time: '2018-10-10T11:41:23.022Z',
expiration_time: '2019-10-10T11:41:23.022Z',
md5_fingerprint: 'asdf',
issuer: 'dn',
},
});

const credentialInUse = Credential.fromElement({
_id: '6575',
allow_insecure: 1,
creation_time: '2020-12-16T15:23:59Z',
comment: 'blah',
formats: {format: 'pem'},
full_type: 'client certificate',
full_type: 'Username + SSH Key',
in_use: 1,
login: '',
modification_time: '2021-03-02T10:28:15Z',
name: 'credential 1',
owner: {name: 'admin'},
permissions: {permission: {name: 'Everything'}},
type: 'cc',
type: 'usk',
writable: 1,
certificate_info: {
activation_time: '2018-10-10T11:41:23.022Z',
expiration_time: '2019-10-10T11:41:23.022Z',
md5_fingerprint: 'asdf',
issuer: 'dn',
},
});

describe('Credential Detailspage tests', () => {
Expand Down Expand Up @@ -186,31 +165,19 @@ describe('Credential Detailspage tests', () => {
expect(element).toHaveTextContent('Owner:admin');

const spans = baseElement.querySelectorAll('span');
expect(spans[10]).toHaveTextContent('User Tags');
expect(spans[12]).toHaveTextContent('Permissions');
expect(spans[12]).toHaveTextContent('User Tags');
expect(spans[14]).toHaveTextContent('Permissions');

expect(element).toHaveTextContent('Comment');
expect(element).toHaveTextContent('blah');

expect(element).toHaveTextContent('Type');
expect(element).toHaveTextContent('Client Certificate(cc)');
expect(element).toHaveTextContent('Username + SSH Key');

expect(element).toHaveTextContent('Allow Insecure Use');
expect(element).toHaveTextContent('Yes');

expect(element).toHaveTextContent('Certificate');

expect(element).toHaveTextContent('Activation');
expect(element).toHaveTextContent('Wed, Oct 10, 2018 1:41 PM CEST');

expect(element).toHaveTextContent('Expiration');
expect(element).toHaveTextContent('Thu, Oct 10, 2019 1:41 PM CEST');

expect(element).toHaveTextContent('MD5 Fingerprint');
expect(element).toHaveTextContent('asdf');

expect(element).toHaveTextContent('Issued By');
expect(element).toHaveTextContent('dn');
expect(element).toHaveTextContent('Login');
});

test('should render user tags tab', () => {
Expand Down Expand Up @@ -243,9 +210,9 @@ describe('Credential Detailspage tests', () => {
const {baseElement} = render(<Detailspage id="6575" />);

const spans = baseElement.querySelectorAll('span');
expect(spans[10]).toHaveTextContent('User Tags');
expect(spans[12]).toHaveTextContent('User Tags');

fireEvent.click(spans[10]);
fireEvent.click(spans[12]);

expect(baseElement).toHaveTextContent('No user tags available');
});
Expand Down Expand Up @@ -280,9 +247,9 @@ describe('Credential Detailspage tests', () => {
const {baseElement} = render(<Detailspage id="6575" />);

const spans = baseElement.querySelectorAll('span');
expect(spans[12]).toHaveTextContent('Permissions');
expect(spans[14]).toHaveTextContent('Permissions');

fireEvent.click(spans[12]);
fireEvent.click(spans[14]);

expect(baseElement).toHaveTextContent('No permissions available');
});
Expand Down Expand Up @@ -428,9 +395,7 @@ describe('Credential ToolBarIcons tests', () => {
const editIcon = screen.getAllByTitle('Edit Credential');
const deleteIcon = screen.getAllByTitle('Move Credential to trashcan');
const exportIcon = screen.getAllByTitle('Export Credential as XML');
const exportCredentialInstallerIcon = screen.getAllByTitle(
'Download Certificate (.pem)',
);
const downloadPublicKeyIcon = screen.getAllByTitle('Download Public Key');

expect(cloneIcon[0]).toBeInTheDocument();
fireEvent.click(cloneIcon[0]);
Expand All @@ -448,11 +413,11 @@ describe('Credential ToolBarIcons tests', () => {
fireEvent.click(exportIcon[0]);
expect(handleCredentialDownloadClick).toHaveBeenCalledWith(credential);

expect(exportCredentialInstallerIcon[0]).toBeInTheDocument();
fireEvent.click(exportCredentialInstallerIcon[0]);
expect(downloadPublicKeyIcon[0]).toBeInTheDocument();
fireEvent.click(downloadPublicKeyIcon[0]);
expect(handleCredentialInstallerDownloadClick).toHaveBeenCalledWith(
credential,
'pem',
'key',
);
});

Expand Down
44 changes: 5 additions & 39 deletions src/web/pages/credentials/__tests__/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ const credential = Credential.fromElement({
creation_time: '2020-12-16T15:23:59Z',
comment: 'blah',
formats: {format: 'pem'},
full_type: 'client certificate',
full_type: 'Username + SSH Key',
in_use: 0,
login: '',
modification_time: '2021-03-02T10:28:15Z',
name: 'credential 1',
owner: {name: 'admin'},
permissions: {permission: {name: 'Everything'}},
type: 'cc',
type: 'usk',
writable: 1,
});

Expand Down Expand Up @@ -134,7 +134,7 @@ describe('CredentialsDialog component tests', () => {
expect(commentInput).toHaveAttribute('value', 'blah');

expect(formGroups[2]).toHaveTextContent('Type');
expect(selectedValue).toHaveTextContent('Client Certificate');
timopollmeier marked this conversation as resolved.
Show resolved Hide resolved
expect(selectedValue).toHaveTextContent('Username + SSH Key');

const allowInsecure = getAllByName('allow_insecure');
expect(formGroups[3]).toHaveTextContent('Allow insecure use');
Expand Down Expand Up @@ -217,8 +217,8 @@ describe('CredentialsDialog component tests', () => {

const selectItems = getAllByTestId('select-item');

expect(selectItems.length).toBe(7);
fireEvent.click(selectItems[6]);
expect(selectItems.length).toBe(6);
fireEvent.click(selectItems[5]);

expect(selectedValues[0]).toHaveTextContent('Password only');

Expand Down Expand Up @@ -298,40 +298,6 @@ describe('CredentialsDialog component tests', () => {
expect(privateKey).toHaveAttribute('type', 'file');
});

test('should render form fields for Client Certificate', () => {
const {render} = rendererWith({
capabilities: true,
});

const {getAllByTestId, getByName} = render(
<CredentialsDialog
credential_type={'cc'}
types={ALL_CREDENTIAL_TYPES}
onClose={handleClose}
onSave={handleSave}
onErrorClose={handleErrorClose}
/>,
);

const selectedValues = getAllByTestId('select-selected-value');

expect(selectedValues[0]).toHaveTextContent('Client Certificate');

const formGroups = getAllByTestId('formgroup-title');

const password = getByName('passphrase');
expect(formGroups[4]).toHaveTextContent('Passphrase');
expect(password).toHaveAttribute('value', '');

const certificate = getByName('certificate');
expect(formGroups[5]).toHaveTextContent('Certificate');
expect(certificate).toHaveAttribute('type', 'file');

const privateKey = getByName('private_key');
expect(formGroups[6]).toHaveTextContent('Private Key');
expect(privateKey).toHaveAttribute('type', 'file');
});

test('should render form fields for SNMP', () => {
const {render} = rendererWith({
capabilities: true,
Expand Down
10 changes: 4 additions & 6 deletions src/web/pages/credentials/__tests__/listpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ const credential = Credential.fromElement({
creation_time: '2020-12-16T15:23:59Z',
comment: 'blah',
formats: {format: 'pem'},
full_type: 'client certificate',
full_type: 'Username + SSH Key',
in_use: 0,
login: '',
modification_time: '2021-03-02T10:28:15Z',
name: 'credential 1',
owner: {name: 'admin'},
permissions: {permission: {name: 'Everything'}},
type: 'cc',
type: 'usk',
writable: 1,
certificate_info: {
activation_time: '2018-10-10T11:41:23.022Z',
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('CredentialPage tests', () => {

expect(row[1]).toHaveTextContent('credential 1');
expect(row[1]).toHaveTextContent('(blah)');
expect(row[1]).toHaveTextContent('Client Certificate(cc)');
timopollmeier marked this conversation as resolved.
Show resolved Hide resolved
expect(row[1]).toHaveTextContent('Username + SSH Key');
expect(row[1]).toHaveTextContent('Yes');

expect(
Expand All @@ -175,9 +175,7 @@ describe('CredentialPage tests', () => {
expect(screen.getAllByTitle('Edit Credential')[0]).toBeInTheDocument();
expect(screen.getAllByTitle('Clone Credential')[0]).toBeInTheDocument();
expect(screen.getAllByTitle('Export Credential')[0]).toBeInTheDocument();
expect(
screen.getAllByTitle('Download Certificate (.pem)')[0],
).toBeInTheDocument();
expect(screen.getAllByTitle('Download Public Key')[0]).toBeInTheDocument();
});

test('should allow to bulk action on page contents', async () => {
Expand Down
11 changes: 4 additions & 7 deletions src/web/pages/credentials/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import React from 'react';
import _ from 'gmp/locale';

import {
CLIENT_CERTIFICATE_CREDENTIAL_TYPE,
SNMP_CREDENTIAL_TYPE,
SNMP_PRIVACY_ALOGRITHM_NONE,
getCredentialTypeName,
Expand Down Expand Up @@ -86,12 +85,10 @@ const CredentialDetails = ({entity}) => {
</TableData>
</TableRow>

{credential_type !== CLIENT_CERTIFICATE_CREDENTIAL_TYPE && (
<TableRow>
<TableData>{_('Login')}</TableData>
<TableData>{login}</TableData>
</TableRow>
)}
<TableRow>
<TableData>{_('Login')}</TableData>
<TableData>{login}</TableData>
</TableRow>
{credential_type === SNMP_CREDENTIAL_TYPE && (
<TableRow>
<TableData>{_('Auth Algorithm')}</TableData>
Expand Down
Loading