-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add snapshot tests for registry configuration (#130)
Jira: EPMDPEDP-13007 Related: #130 Change-Id: I716355d7b12d6e5f4d456f464896f3b3f3c2fc7c
- Loading branch information
1 parent
95131d5
commit 4024cb8
Showing
18 changed files
with
6,580 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ValueOf } from '../../../types/global'; | ||
import { CONTAINER_REGISTRY_PLATFORM, CONTAINER_REGISTRY_TYPE } from '../constants'; | ||
|
||
export const createEmptyEdpConfigMapMock = ( | ||
platform: ValueOf<typeof CONTAINER_REGISTRY_PLATFORM> | ||
) => ({ | ||
metadata: { | ||
name: 'edp-config', | ||
namespace: 'test-namespace', | ||
}, | ||
data: { | ||
aws_region: 'eu-central-1', | ||
container_registry_host: 'registry.test.com', | ||
container_registry_space: 'test-namespace', | ||
container_registry_type: '', | ||
dns_wildcard: 'test-dns-wildcard', | ||
edp_name: 'test-namespace', | ||
edp_version: '3.8.0-SNAPSHOT.23', | ||
platform: platform, | ||
}, | ||
kind: 'ConfigMap', | ||
}); | ||
|
||
export const createEdpConfigMapMock = ( | ||
type: ValueOf<typeof CONTAINER_REGISTRY_TYPE>, | ||
platform: ValueOf<typeof CONTAINER_REGISTRY_PLATFORM> | ||
) => ({ | ||
metadata: { | ||
name: 'edp-config', | ||
namespace: 'test-namespace', | ||
}, | ||
data: { | ||
aws_region: 'eu-central-1', | ||
container_registry_host: 'registry.test.com', | ||
container_registry_space: 'test-namespace', | ||
container_registry_type: type, | ||
dns_wildcard: 'test-dns-wildcard', | ||
edp_name: 'test-namespace', | ||
edp_version: '3.8.0-SNAPSHOT.23', | ||
platform: platform, | ||
}, | ||
kind: 'ConfigMap', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Encoded data | ||
"auths": { | ||
"registry.test.com": { | ||
"username": "test-username", | ||
"password": "test-password", | ||
"auth": "test-auth" | ||
} | ||
} | ||
*/ | ||
|
||
export const kanikoDockerSecretMock = { | ||
metadata: { | ||
name: 'kaniko-docker-config', | ||
namespace: 'test-namespace', | ||
labels: { | ||
'app.edp.epam.com/integration-secret': 'true', | ||
'app.edp.epam.com/secret-type': 'registry', | ||
}, | ||
annotations: { | ||
'app.edp.epam.com/integration-secret-connected': 'true', | ||
}, | ||
}, | ||
immutable: false, | ||
data: { | ||
'.dockerconfigjson': | ||
'eyJhdXRocyI6eyJyZWdpc3RyeS50ZXN0LmNvbSI6eyJ1c2VybmFtZSI6InRlc3QtdXNlcm5hbWUiLCJwYXNzd29yZCI6InRlc3QtcGFzc3dvcmQiLCJhdXRoIjoidGVzdC1hdXRoIn19fQ==', | ||
}, | ||
type: 'kubernetes.io/dockerconfigjson', | ||
kind: 'Secret', | ||
apiVersion: 'v1', | ||
}; | ||
|
||
export const kanikoDockerSecretWithOwnerMock = { | ||
metadata: { | ||
name: 'kaniko-docker-config', | ||
namespace: 'test-namespace', | ||
labels: { | ||
'app.edp.epam.com/integration-secret': 'true', | ||
'app.edp.epam.com/secret-type': 'registry', | ||
}, | ||
annotations: { | ||
'app.edp.epam.com/integration-secret-connected': 'true', | ||
}, | ||
ownerReferences: [ | ||
{ | ||
apiVersion: 'external-secrets.io/v1beta1', | ||
kind: 'ExternalSecret', | ||
name: 'kaniko-docker-config', | ||
controller: true, | ||
blockOwnerDeletion: true, | ||
}, | ||
], | ||
}, | ||
immutable: false, | ||
data: { | ||
'.dockerconfigjson': | ||
'eyJhdXRocyI6eyJyZWdpc3RyeS50ZXN0LmNvbSI6eyJ1c2VybmFtZSI6InRlc3QtdXNlcm5hbWUiLCJwYXNzd29yZCI6InRlc3QtcGFzc3dvcmQiLCJhdXRoIjoidGVzdC1hdXRoIn19fQ==', | ||
}, | ||
type: 'kubernetes.io/dockerconfigjson', | ||
kind: 'Secret', | ||
apiVersion: 'v1', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Encoded data | ||
"auths": { | ||
"registry.test.com": { | ||
"username": "test-username", | ||
"password": "test-password", | ||
"auth": "test-auth" | ||
} | ||
} | ||
*/ | ||
|
||
export const regcredSecretMock = { | ||
metadata: { | ||
name: 'regcred', | ||
namespace: 'test-namespace', | ||
labels: { | ||
'app.edp.epam.com/integration-secret': 'true', | ||
'app.edp.epam.com/secret-type': 'registry', | ||
}, | ||
annotations: { | ||
'app.edp.epam.com/integration-secret-connected': 'true', | ||
}, | ||
}, | ||
immutable: false, | ||
data: { | ||
'.dockerconfigjson': | ||
'eyJhdXRocyI6eyJyZWdpc3RyeS50ZXN0LmNvbSI6eyJ1c2VybmFtZSI6InRlc3QtdXNlcm5hbWUiLCJwYXNzd29yZCI6InRlc3QtcGFzc3dvcmQiLCJhdXRoIjoidGVzdC1hdXRoIn19fQ==', | ||
}, | ||
type: 'kubernetes.io/dockerconfigjson', | ||
kind: 'Secret', | ||
apiVersion: 'v1', | ||
}; | ||
|
||
export const regcredSecretWithOwnerMock = { | ||
metadata: { | ||
name: 'regcred', | ||
namespace: 'test-namespace', | ||
labels: { | ||
'app.edp.epam.com/integration-secret': 'true', | ||
'app.edp.epam.com/secret-type': 'registry', | ||
}, | ||
annotations: { | ||
'app.edp.epam.com/integration-secret-connected': 'true', | ||
}, | ||
ownerReferences: [ | ||
{ | ||
apiVersion: 'external-secrets.io/v1beta1', | ||
kind: 'ExternalSecret', | ||
name: 'regcred', | ||
controller: true, | ||
blockOwnerDeletion: true, | ||
}, | ||
], | ||
}, | ||
immutable: false, | ||
data: { | ||
'.dockerconfigjson': | ||
'eyJhdXRocyI6eyJyZWdpc3RyeS50ZXN0LmNvbSI6eyJ1c2VybmFtZSI6InRlc3QtdXNlcm5hbWUiLCJwYXNzd29yZCI6InRlc3QtcGFzc3dvcmQiLCJhdXRoIjoidGVzdC1hdXRoIn19fQ==', | ||
}, | ||
type: 'kubernetes.io/dockerconfigjson', | ||
kind: 'Secret', | ||
apiVersion: 'v1', | ||
}; |
1 change: 1 addition & 0 deletions
1
src/pages/edp-component-details/components/CodebaseMetadataTable/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/widgets/DeeptrackVulnerabilities/components/NoDataSvg/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,780 changes: 1,780 additions & 0 deletions
1,780
src/widgets/ManageRegistry/__snapshots__/index.create.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
2,247 changes: 2,247 additions & 0 deletions
2,247
src/widgets/ManageRegistry/__snapshots__/index.edit.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
2,260 changes: 2,260 additions & 0 deletions
2,260
src/widgets/ManageRegistry/__snapshots__/index.read.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { TestWrapper } from '../../../mocks/wrappers/default'; | ||
import { CONTAINER_REGISTRY_PLATFORM } from '../../k8s/ConfigMap/constants'; | ||
import { createEmptyEdpConfigMapMock } from '../../k8s/ConfigMap/mocks/edp-config-map.mock'; | ||
import { ConfigMapKubeObjectInterface } from '../../k8s/ConfigMap/types'; | ||
import { ManageRegistry } from './index'; | ||
|
||
test('renders ManageRegistry Kubernetes Create component', () => { | ||
render( | ||
<TestWrapper> | ||
<ManageRegistry | ||
formData={{ | ||
EDPConfigMap: createEmptyEdpConfigMapMock( | ||
CONTAINER_REGISTRY_PLATFORM.KUBERNETES | ||
) as unknown as ConfigMapKubeObjectInterface, | ||
pullAccountSecret: null, | ||
pushAccountSecret: null, | ||
tektonServiceAccount: null, | ||
}} | ||
/> | ||
</TestWrapper> | ||
); | ||
|
||
const dialog = screen.getByTestId('form'); | ||
expect(dialog).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { TestWrapper } from '../../../mocks/wrappers/default'; | ||
import { | ||
CONTAINER_REGISTRY_PLATFORM, | ||
CONTAINER_REGISTRY_TYPE, | ||
} from '../../k8s/ConfigMap/constants'; | ||
import { createEdpConfigMapMock } from '../../k8s/ConfigMap/mocks/edp-config-map.mock'; | ||
import { ConfigMapKubeObjectInterface } from '../../k8s/ConfigMap/types'; | ||
import { kanikoDockerSecretMock } from '../../k8s/Secret/mocks/kaniko-config-secret.mock'; | ||
import { regcredSecretMock } from '../../k8s/Secret/mocks/regcred-config-secret.mock'; | ||
import { SecretKubeObjectInterface } from '../../k8s/Secret/types'; | ||
import { ManageRegistry } from './index'; | ||
|
||
test('renders ManageRegistry Kubernetes Edit component', () => { | ||
render( | ||
<TestWrapper> | ||
<ManageRegistry | ||
formData={{ | ||
EDPConfigMap: createEdpConfigMapMock( | ||
CONTAINER_REGISTRY_TYPE.HARBOR, | ||
CONTAINER_REGISTRY_PLATFORM.KUBERNETES | ||
) as unknown as ConfigMapKubeObjectInterface, | ||
pullAccountSecret: regcredSecretMock as unknown as SecretKubeObjectInterface, | ||
pushAccountSecret: | ||
kanikoDockerSecretMock as unknown as SecretKubeObjectInterface, | ||
tektonServiceAccount: null, | ||
}} | ||
/> | ||
</TestWrapper> | ||
); | ||
|
||
const dialog = screen.getByTestId('form'); | ||
expect(dialog).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { TestWrapper } from '../../../mocks/wrappers/default'; | ||
import { | ||
CONTAINER_REGISTRY_PLATFORM, | ||
CONTAINER_REGISTRY_TYPE, | ||
} from '../../k8s/ConfigMap/constants'; | ||
import { createEdpConfigMapMock } from '../../k8s/ConfigMap/mocks/edp-config-map.mock'; | ||
import { ConfigMapKubeObjectInterface } from '../../k8s/ConfigMap/types'; | ||
import { kanikoDockerSecretWithOwnerMock } from '../../k8s/Secret/mocks/kaniko-config-secret.mock'; | ||
import { regcredSecretWithOwnerMock } from '../../k8s/Secret/mocks/regcred-config-secret.mock'; | ||
import { SecretKubeObjectInterface } from '../../k8s/Secret/types'; | ||
import { ManageRegistry } from './index'; | ||
|
||
test('renders ManageRegistry Kubernetes Edit (read-only) component', () => { | ||
render( | ||
<TestWrapper> | ||
<ManageRegistry | ||
formData={{ | ||
EDPConfigMap: createEdpConfigMapMock( | ||
CONTAINER_REGISTRY_TYPE.HARBOR, | ||
CONTAINER_REGISTRY_PLATFORM.KUBERNETES | ||
) as unknown as ConfigMapKubeObjectInterface, | ||
pullAccountSecret: | ||
regcredSecretWithOwnerMock as unknown as SecretKubeObjectInterface, | ||
pushAccountSecret: | ||
kanikoDockerSecretWithOwnerMock as unknown as SecretKubeObjectInterface, | ||
tektonServiceAccount: null, | ||
}} | ||
/> | ||
</TestWrapper> | ||
); | ||
|
||
const dialog = screen.getByTestId('form'); | ||
expect(dialog).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters