Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 12:08:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 12:08:49 +0300
commitc31a6781a356297f77dd87af4826ead582bbcb34 (patch)
tree2ccf6255b1256de2e13db781b1cd09b07c2d79f9 /spec/frontend/ci_secure_files
parent8ebab6079e4d9c834435e8241cada4122d32673f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ci_secure_files')
-rw-r--r--spec/frontend/ci_secure_files/components/metadata/__snapshots__/modal_spec.js.snap386
-rw-r--r--spec/frontend/ci_secure_files/components/metadata/button_spec.js49
-rw-r--r--spec/frontend/ci_secure_files/components/metadata/modal_spec.js78
-rw-r--r--spec/frontend/ci_secure_files/mock_data.js61
4 files changed, 572 insertions, 2 deletions
diff --git a/spec/frontend/ci_secure_files/components/metadata/__snapshots__/modal_spec.js.snap b/spec/frontend/ci_secure_files/components/metadata/__snapshots__/modal_spec.js.snap
new file mode 100644
index 00000000000..b2084e3a7de
--- /dev/null
+++ b/spec/frontend/ci_secure_files/components/metadata/__snapshots__/modal_spec.js.snap
@@ -0,0 +1,386 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Secure File Metadata Modal when a .cer file is supplied matches cer the snapshot 1`] = `
+<div
+ category="primary"
+ hide-footer=""
+>
+ <div
+ data-testid="slot-modal-title"
+ >
+ myfile.cer Metadata
+ </div>
+ <div
+ data-testid="slot-default"
+ >
+
+ <table
+ aria-busy="false"
+ aria-colcount="2"
+ class="table b-table gl-table"
+ role="table"
+ >
+ <!---->
+ <!---->
+ <thead
+ class=""
+ role="rowgroup"
+ >
+ <!---->
+ <tr
+ class=""
+ role="row"
+ >
+ <th
+ aria-colindex="1"
+ class="hidden"
+ role="columnheader"
+ scope="col"
+ >
+ <div>
+ Item Name
+ </div>
+ </th>
+ <th
+ aria-colindex="2"
+ class="hidden"
+ role="columnheader"
+ scope="col"
+ >
+ <div>
+ Item Data
+ </div>
+ </th>
+ </tr>
+ </thead>
+ <tbody
+ role="rowgroup"
+ >
+ <!---->
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ Name
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ Apple Distribution: Team Name (ABC123XYZ)
+
+ </td>
+ </tr>
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ Serial
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ 33669367788748363528491290218354043267
+
+ </td>
+ </tr>
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ Team
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ Team Name (ABC123XYZ)
+
+ </td>
+ </tr>
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ Issuer
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ Apple Worldwide Developer Relations Certification Authority - G3
+
+ </td>
+ </tr>
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ Expires at
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ April 26, 2022 at 7:20:40 PM GMT
+
+ </td>
+ </tr>
+ <!---->
+ <!---->
+ </tbody>
+ <!---->
+ </table>
+ </div>
+</div>
+`;
+
+exports[`Secure File Metadata Modal when a .mobileprovision file is supplied matches the mobileprovision snapshot 1`] = `
+<div
+ category="primary"
+ hide-footer=""
+>
+ <div
+ data-testid="slot-modal-title"
+ >
+ sample.mobileprovision Metadata
+ </div>
+ <div
+ data-testid="slot-default"
+ >
+
+ <table
+ aria-busy="false"
+ aria-colcount="2"
+ class="table b-table gl-table"
+ role="table"
+ >
+ <!---->
+ <!---->
+ <thead
+ class=""
+ role="rowgroup"
+ >
+ <!---->
+ <tr
+ class=""
+ role="row"
+ >
+ <th
+ aria-colindex="1"
+ class="hidden"
+ role="columnheader"
+ scope="col"
+ >
+ <div>
+ Item Name
+ </div>
+ </th>
+ <th
+ aria-colindex="2"
+ class="hidden"
+ role="columnheader"
+ scope="col"
+ >
+ <div>
+ Item Data
+ </div>
+ </th>
+ </tr>
+ </thead>
+ <tbody
+ role="rowgroup"
+ >
+ <!---->
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ UUID
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ 6b9fcce1-b9a9-4b37-b2ce-ec4da2044abf
+
+ </td>
+ </tr>
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ Platforms
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ iOS
+
+ </td>
+ </tr>
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ Team
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ Team Name (ABC123XYZ)
+
+ </td>
+ </tr>
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ App
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ iOS Demo - match Development com.gitlab.ios-demo
+
+ </td>
+ </tr>
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ Certificates
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ 33669367788748363528491290218354043267
+
+ </td>
+ </tr>
+ <tr
+ class=""
+ role="row"
+ >
+ <td
+ aria-colindex="1"
+ class=""
+ role="cell"
+ >
+ <strong>
+ Expires at
+ </strong>
+ </td>
+ <td
+ aria-colindex="2"
+ class=""
+ role="cell"
+ >
+
+ August 1, 2023 at 11:15:13 PM GMT
+
+ </td>
+ </tr>
+ <!---->
+ <!---->
+ </tbody>
+ <!---->
+ </table>
+ </div>
+</div>
+`;
diff --git a/spec/frontend/ci_secure_files/components/metadata/button_spec.js b/spec/frontend/ci_secure_files/components/metadata/button_spec.js
new file mode 100644
index 00000000000..4ac5b3325d4
--- /dev/null
+++ b/spec/frontend/ci_secure_files/components/metadata/button_spec.js
@@ -0,0 +1,49 @@
+import { GlButton } from '@gitlab/ui';
+import { mount } from '@vue/test-utils';
+import Button from '~/ci_secure_files/components/metadata/button.vue';
+import { secureFiles } from '../../mock_data';
+
+const secureFileWithoutMetadata = secureFiles[0];
+const secureFileWithMetadata = secureFiles[2];
+const modalId = 'metadataModalId';
+
+describe('Secure File Metadata Button', () => {
+ let wrapper;
+
+ const findButton = () => wrapper.findComponent(GlButton);
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ const createWrapper = (secureFile = {}, admin = false) => {
+ wrapper = mount(Button, {
+ propsData: {
+ admin,
+ modalId,
+ secureFile,
+ },
+ });
+ };
+
+ describe('metadata button visibility', () => {
+ it.each`
+ visibility | admin | fileName
+ ${true} | ${true} | ${secureFileWithMetadata}
+ ${false} | ${false} | ${secureFileWithMetadata}
+ ${false} | ${false} | ${secureFileWithoutMetadata}
+ ${false} | ${false} | ${secureFileWithoutMetadata}
+ `(
+ 'button visibility is $visibility when admin equals $admin and $fileName.name is suppled',
+ ({ visibility, admin, fileName }) => {
+ createWrapper(fileName, admin);
+ expect(findButton().exists()).toBe(visibility);
+
+ if (visibility) {
+ expect(findButton().isVisible()).toBe(true);
+ expect(findButton().attributes('aria-label')).toBe('View File Metadata');
+ }
+ },
+ );
+ });
+});
diff --git a/spec/frontend/ci_secure_files/components/metadata/modal_spec.js b/spec/frontend/ci_secure_files/components/metadata/modal_spec.js
new file mode 100644
index 00000000000..230507d32d7
--- /dev/null
+++ b/spec/frontend/ci_secure_files/components/metadata/modal_spec.js
@@ -0,0 +1,78 @@
+import { GlModal } from '@gitlab/ui';
+import { mount } from '@vue/test-utils';
+import { stubComponent, RENDER_ALL_SLOTS_TEMPLATE } from 'helpers/stub_component';
+import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
+
+import Modal from '~/ci_secure_files/components/metadata/modal.vue';
+
+import { secureFiles } from '../../mock_data';
+
+const cerFile = secureFiles[2];
+const mobileprovisionFile = secureFiles[3];
+const modalId = 'metadataModalId';
+
+describe('Secure File Metadata Modal', () => {
+ let wrapper;
+ let trackingSpy;
+
+ const createWrapper = (secureFile = {}) => {
+ wrapper = mount(Modal, {
+ stubs: {
+ GlModal: stubComponent(GlModal, {
+ template: RENDER_ALL_SLOTS_TEMPLATE,
+ }),
+ },
+ propsData: {
+ modalId,
+ name: secureFile.name,
+ metadata: secureFile.metadata,
+ fileExtension: secureFile.file_extension,
+ },
+ });
+ };
+
+ beforeEach(() => {
+ trackingSpy = mockTracking(undefined, undefined, jest.spyOn);
+ });
+
+ afterEach(() => {
+ unmockTracking();
+ wrapper.destroy();
+ });
+
+ describe('when a .cer file is supplied', () => {
+ it('matches cer the snapshot', () => {
+ createWrapper(cerFile);
+ expect(wrapper.element).toMatchSnapshot();
+ });
+ });
+
+ describe('when a .mobileprovision file is supplied', () => {
+ it('matches the mobileprovision snapshot', () => {
+ createWrapper(mobileprovisionFile);
+ expect(wrapper.element).toMatchSnapshot();
+ });
+ });
+
+ describe('event tracking', () => {
+ it('sends cer tracking information when the modal is loaded', () => {
+ createWrapper(cerFile);
+ expect(trackingSpy).toHaveBeenCalledWith(undefined, 'load_secure_file_metadata_cer', {});
+ expect(trackingSpy).not.toHaveBeenCalledWith(
+ undefined,
+ 'load_secure_file_metadata_mobileprovision',
+ {},
+ );
+ });
+
+ it('sends mobileprovision tracking information when the modal is loaded', () => {
+ createWrapper(mobileprovisionFile);
+ expect(trackingSpy).toHaveBeenCalledWith(
+ undefined,
+ 'load_secure_file_metadata_mobileprovision',
+ {},
+ );
+ expect(trackingSpy).not.toHaveBeenCalledWith(undefined, 'load_secure_file_metadata_cer', {});
+ });
+ });
+});
diff --git a/spec/frontend/ci_secure_files/mock_data.js b/spec/frontend/ci_secure_files/mock_data.js
index 5a9e16d1ad6..f532b468fb9 100644
--- a/spec/frontend/ci_secure_files/mock_data.js
+++ b/spec/frontend/ci_secure_files/mock_data.js
@@ -4,15 +4,72 @@ export const secureFiles = [
name: 'myfile.jks',
checksum: '16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac',
checksum_algorithm: 'sha256',
- permissions: 'read_only',
created_at: '2022-02-22T22:22:22.222Z',
+ file_extension: 'jks',
+ metadata: null,
},
{
id: 2,
name: 'myotherfile.jks',
checksum: '16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aa2',
checksum_algorithm: 'sha256',
- permissions: 'execute',
created_at: '2022-02-22T22:22:22.222Z',
+ file_extension: 'jks',
+ metadata: null,
+ },
+ {
+ id: 3,
+ name: 'myfile.cer',
+ checksum: '16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aa2',
+ checksum_algorithm: 'sha256',
+ created_at: '2022-02-22T22:22:22.222Z',
+ file_extension: 'cer',
+ expires_at: '2022-04-26T19:20:40.000Z',
+ metadata: {
+ id: '33669367788748363528491290218354043267',
+ issuer: {
+ C: 'US',
+ O: 'Apple Inc.',
+ CN: 'Apple Worldwide Developer Relations Certification Authority',
+ OU: 'G3',
+ },
+ subject: {
+ C: 'US',
+ O: 'Team Name',
+ CN: 'Apple Distribution: Team Name (ABC123XYZ)',
+ OU: 'ABC123XYZ',
+ UID: 'ABC123XYZ',
+ },
+ expires_at: '2022-04-26T19:20:40.000Z',
+ },
+ },
+ {
+ id: 4,
+ name: 'sample.mobileprovision',
+ checksum: '9e194bbde00d57c64b6640ed2c9e166d76b4c79d9dbd49770f95be56678f2a62',
+ checksum_algorithm: 'sha256',
+ created_at: '2022-11-15T19:29:57.577Z',
+ expires_at: '2023-08-01T23:15:13.000Z',
+ metadata: {
+ id: '6b9fcce1-b9a9-4b37-b2ce-ec4da2044abf',
+ app_id: 'match Development com.gitlab.ios-demo',
+ devices: ['00008101-001454860C10001E'],
+ team_id: ['ABC123XYZ'],
+ app_name: 'iOS Demo',
+ platforms: ['iOS'],
+ team_name: 'Team Name',
+ expires_at: '2023-08-01T18:15:13.000-05:00',
+ entitlements: {
+ 'get-task-allow': true,
+ 'application-identifier': 'N7SYAN8PX8.com.gitlab.ios-demo',
+ 'keychain-access-groups': ['ABC123XYZ.*', 'com.apple.token'],
+ 'com.apple.developer.game-center': true,
+ 'com.apple.developer.team-identifier': 'ABC123XYZ',
+ },
+ app_id_prefix: ['ABC123XYZ'],
+ xcode_managed: false,
+ certificate_ids: ['33669367788748363528491290218354043267'],
+ },
+ file_extension: 'mobileprovision',
},
];