diff --git a/.github/workflows/build-ui.yml b/.github/workflows/build-ui.yml new file mode 100644 index 0000000000..48c5c1f2ae --- /dev/null +++ b/.github/workflows/build-ui.yml @@ -0,0 +1,48 @@ +# Copyright 2024 Specter Ops, Inc. +# +# Licensed under the Apache License, Version 2.0 +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +name: Build UI + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize] + +jobs: + build-ui: + runs-on: ubuntu-latest + + steps: + - name: Checkout source code for this repository + uses: actions/checkout@v3 + + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Install Yarn + run: | + npm install --global yarn + + - name: Install Deps + run: | + cd cmd/ui && yarn + + - name: Run Build + run: | + cd cmd/ui && yarn build diff --git a/packages/javascript/bh-shared-ui/package.json b/packages/javascript/bh-shared-ui/package.json index 180249e5fc..2d00a3e896 100644 --- a/packages/javascript/bh-shared-ui/package.json +++ b/packages/javascript/bh-shared-ui/package.json @@ -9,7 +9,7 @@ ], "type": "module", "scripts": { - "build": "rollup -c rollup.config.js", + "build": "yarn check-types && rollup -c rollup.config.js", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "test": "TZ=America/Los_Angeles vitest", "check-types": "tsc --noEmit --pretty", diff --git a/packages/javascript/bh-shared-ui/rollup.config.js b/packages/javascript/bh-shared-ui/rollup.config.js index b976f9ded5..c238461c10 100644 --- a/packages/javascript/bh-shared-ui/rollup.config.js +++ b/packages/javascript/bh-shared-ui/rollup.config.js @@ -57,6 +57,7 @@ export default { 'notistack', 'react-query', 'js-client-library', + 'js-file-download', 'swagger-ui-react', 'swagger-ui-react/swagger-ui.css', 'prop-types', diff --git a/packages/javascript/bh-shared-ui/src/components/CreateUserDialog/CreateUserDialog.test.tsx b/packages/javascript/bh-shared-ui/src/components/CreateUserDialog/CreateUserDialog.test.tsx index 088a3c3cbf..f13e0ea360 100644 --- a/packages/javascript/bh-shared-ui/src/components/CreateUserDialog/CreateUserDialog.test.tsx +++ b/packages/javascript/bh-shared-ui/src/components/CreateUserDialog/CreateUserDialog.test.tsx @@ -43,6 +43,8 @@ const testSSOProviders: SSOProvider[] = [ sp_metadata_uri: '', sp_acs_uri: '', } as SAMLProviderInfo, + login_uri: '', + callback_uri: '', created_at: '', updated_at: '', }, @@ -60,6 +62,8 @@ const testSSOProviders: SSOProvider[] = [ sp_metadata_uri: '', sp_acs_uri: '', } as SAMLProviderInfo, + login_uri: '', + callback_uri: '', created_at: '', updated_at: '', }, @@ -77,6 +81,8 @@ const testSSOProviders: SSOProvider[] = [ sp_metadata_uri: '', sp_acs_uri: '', } as SAMLProviderInfo, + login_uri: '', + callback_uri: '', created_at: '', updated_at: '', }, @@ -94,6 +100,8 @@ const testSSOProviders: SSOProvider[] = [ sp_metadata_uri: '', sp_acs_uri: '', } as SAMLProviderInfo, + login_uri: '', + callback_uri: '', created_at: '', updated_at: '', }, diff --git a/packages/javascript/bh-shared-ui/src/components/LoginViaSSOForm/LoginViaSSOForm.test.tsx b/packages/javascript/bh-shared-ui/src/components/LoginViaSSOForm/LoginViaSSOForm.test.tsx index 42be06a211..292742ccbf 100644 --- a/packages/javascript/bh-shared-ui/src/components/LoginViaSSOForm/LoginViaSSOForm.test.tsx +++ b/packages/javascript/bh-shared-ui/src/components/LoginViaSSOForm/LoginViaSSOForm.test.tsx @@ -32,6 +32,8 @@ const testSSOProviders: SSOProvider[] = [ created_at: '', updated_at: '', }, + login_uri: '', + callback_uri: '', id: 1, created_at: '', updated_at: '', @@ -55,6 +57,8 @@ const testSSOProviders: SSOProvider[] = [ created_at: '', updated_at: '', }, + login_uri: '', + callback_uri: '', id: 2, created_at: '', updated_at: '', diff --git a/packages/javascript/bh-shared-ui/src/components/SSOProviderInfoPanel/SSOProviderInfoPanel.test.tsx b/packages/javascript/bh-shared-ui/src/components/SSOProviderInfoPanel/SSOProviderInfoPanel.test.tsx index 1763464ccc..0f09c29609 100644 --- a/packages/javascript/bh-shared-ui/src/components/SSOProviderInfoPanel/SSOProviderInfoPanel.test.tsx +++ b/packages/javascript/bh-shared-ui/src/components/SSOProviderInfoPanel/SSOProviderInfoPanel.test.tsx @@ -33,6 +33,8 @@ const samlProvider: SSOProvider = { sp_metadata_uri: 'http://bloodhound.localhost/api/v2/login/saml/test-idp-2/metadata', sp_acs_uri: 'http://bloodhound.localhost/api/v2/login/saml/test-idp-2/acs', } as SAMLProviderInfo, + login_uri: '', + callback_uri: '', created_at: '2022-02-24T23:38:41.420271Z', updated_at: '2022-02-24T23:38:41.420271Z', }; @@ -46,6 +48,8 @@ const oidcProvider: SSOProvider = { issuer: 'http://bloodhound.localhost/test-idp-2', client_id: 'gotham-oidc', } as OIDCProviderInfo, + login_uri: '', + callback_uri: '', created_at: '2022-02-24T23:38:41.420271Z', updated_at: '2022-02-24T23:38:41.420271Z', }; diff --git a/packages/javascript/bh-shared-ui/src/components/SSOProviderTable/SSOProviderTable.test.tsx b/packages/javascript/bh-shared-ui/src/components/SSOProviderTable/SSOProviderTable.test.tsx index 220df2ca0f..6997e7c343 100644 --- a/packages/javascript/bh-shared-ui/src/components/SSOProviderTable/SSOProviderTable.test.tsx +++ b/packages/javascript/bh-shared-ui/src/components/SSOProviderTable/SSOProviderTable.test.tsx @@ -25,6 +25,8 @@ const samlProvider: SSOProvider = { slug: 'gotham-saml', name: 'Gotham SAML', type: 'SAML', + login_uri: '', + callback_uri: '', created_at: '2022-02-24T23:38:41.420271Z', updated_at: '2022-02-24T23:38:41.420271Z', details: {} as SAMLProviderInfo, @@ -35,6 +37,8 @@ const oidcProvider: SSOProvider = { slug: 'gotham-oidc', name: 'Gotham OIDC', type: 'OIDC', + login_uri: '', + callback_uri: '', created_at: '2022-02-24T23:38:41.420271Z', updated_at: '2022-02-24T23:38:41.420271Z', details: {} as OIDCProviderInfo, @@ -45,6 +49,7 @@ const ssoProviders = [samlProvider, oidcProvider]; describe('SSOProviderTable', () => { const onClickSSOProvider = vi.fn(); const onDeleteSSOProvider = vi.fn(); + const onUpdateSSOProvider = vi.fn(); it('should render', async () => { const onToggleTypeSortOrder = vi.fn(); @@ -55,6 +60,7 @@ describe('SSOProviderTable', () => { loading={false} onClickSSOProvider={onClickSSOProvider} onDeleteSSOProvider={onDeleteSSOProvider} + onUpdateSSOProvider={onUpdateSSOProvider} onToggleTypeSortOrder={onToggleTypeSortOrder} /> ); @@ -82,6 +88,7 @@ describe('SSOProviderTable', () => { loading={false} onClickSSOProvider={onClickSSOProvider} onDeleteSSOProvider={onDeleteSSOProvider} + onUpdateSSOProvider={onUpdateSSOProvider} onToggleTypeSortOrder={onToggleTypeSortOrder} typeSortOrder={typeSortOrder} /> diff --git a/packages/javascript/bh-shared-ui/src/components/UpdateUserDialog/UpdateUserDialog.test.tsx b/packages/javascript/bh-shared-ui/src/components/UpdateUserDialog/UpdateUserDialog.test.tsx index 37a26c9290..dd7a03e515 100644 --- a/packages/javascript/bh-shared-ui/src/components/UpdateUserDialog/UpdateUserDialog.test.tsx +++ b/packages/javascript/bh-shared-ui/src/components/UpdateUserDialog/UpdateUserDialog.test.tsx @@ -48,6 +48,8 @@ const testSSOProviders: SSOProvider[] = [ created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', }, + login_uri: '', + callback_uri: '', id: 1, created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', @@ -71,6 +73,8 @@ const testSSOProviders: SSOProvider[] = [ created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', }, + login_uri: '', + callback_uri: '', id: 2, created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', @@ -94,6 +98,8 @@ const testSSOProviders: SSOProvider[] = [ created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', }, + login_uri: '', + callback_uri: '', id: 3, created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', @@ -117,6 +123,8 @@ const testSSOProviders: SSOProvider[] = [ created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', }, + login_uri: '', + callback_uri: '', id: 4, created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', diff --git a/packages/javascript/bh-shared-ui/src/components/UpsertSAMLProviderForm/UpsertSAMLProviderForm.test.tsx b/packages/javascript/bh-shared-ui/src/components/UpsertSAMLProviderForm/UpsertSAMLProviderForm.test.tsx index 518af2ec47..31c6f8cc4b 100644 --- a/packages/javascript/bh-shared-ui/src/components/UpsertSAMLProviderForm/UpsertSAMLProviderForm.test.tsx +++ b/packages/javascript/bh-shared-ui/src/components/UpsertSAMLProviderForm/UpsertSAMLProviderForm.test.tsx @@ -22,7 +22,7 @@ describe('UpsertSAMLProviderForm', () => { it('should render inputs, labels, and action buttons', () => { const testOnClose = vi.fn(); const testOnSubmit = vi.fn(); - render(); + render(); expect(screen.getByLabelText('SAML Provider Name')).toBeInTheDocument(); @@ -37,7 +37,7 @@ describe('UpsertSAMLProviderForm', () => { const user = userEvent.setup(); const testOnClose = vi.fn(); const testOnSubmit = vi.fn(); - render(); + render(); await user.click(screen.getByRole('button', { name: 'Cancel' })); @@ -48,7 +48,7 @@ describe('UpsertSAMLProviderForm', () => { const user = userEvent.setup(); const testOnClose = vi.fn(); const testOnSubmit = vi.fn(); - render(); + render(); await user.click(screen.getByRole('button', { name: 'Submit' })); @@ -65,7 +65,7 @@ describe('UpsertSAMLProviderForm', () => { const testOnSubmit = vi.fn(); const validProviderName = 'test-provider-name'; const validMetadata = new File([], 'test-metadata.xml'); - render(); + render(); await user.type(screen.getByLabelText('SAML Provider Name'), validProviderName); diff --git a/packages/javascript/bh-shared-ui/src/views/SSOConfiguration/SSOConfiguration.test.tsx b/packages/javascript/bh-shared-ui/src/views/SSOConfiguration/SSOConfiguration.test.tsx index c20baa6a91..d6a13ebbbf 100644 --- a/packages/javascript/bh-shared-ui/src/views/SSOConfiguration/SSOConfiguration.test.tsx +++ b/packages/javascript/bh-shared-ui/src/views/SSOConfiguration/SSOConfiguration.test.tsx @@ -35,6 +35,8 @@ const initialSAMLProvider: SSOProvider = { sp_metadata_uri: 'http://bloodhound.localhost/api/v2/login/saml/test-idp-1/metadata', sp_acs_uri: 'http://bloodhound.localhost/api/v2/login/saml/test-idp-1/acs', } as SAMLProviderInfo, + login_uri: '', + callback_uri: '', created_at: '2022-02-24T23:38:41.420271Z', updated_at: '2022-02-24T23:38:41.420271Z', }; @@ -55,6 +57,8 @@ const newSAMLProvider: SSOProvider = { sp_metadata_uri: 'http://bloodhound.localhost/api/v2/login/saml/test-idp-2/metadata', sp_acs_uri: 'http://bloodhound.localhost/api/v2/login/saml/test-idp-2/acs', } as SAMLProviderInfo, + login_uri: '', + callback_uri: '', created_at: new Date().toISOString(), updated_at: new Date().toISOString(), }; diff --git a/packages/javascript/bh-shared-ui/src/views/Users/Users.test.tsx b/packages/javascript/bh-shared-ui/src/views/Users/Users.test.tsx index bab27dc271..d116dc1523 100644 --- a/packages/javascript/bh-shared-ui/src/views/Users/Users.test.tsx +++ b/packages/javascript/bh-shared-ui/src/views/Users/Users.test.tsx @@ -113,6 +113,8 @@ const testSSOProviders: SSOProvider[] = [ created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', }, + login_uri: '', + callback_uri: '', id: 1, created_at: '2024-01-01T12:00:00Z', updated_at: '2024-01-01T12:00:00Z', diff --git a/packages/javascript/js-client-library/package.json b/packages/javascript/js-client-library/package.json index 3a1a8d0fe0..571cff39ac 100644 --- a/packages/javascript/js-client-library/package.json +++ b/packages/javascript/js-client-library/package.json @@ -9,7 +9,7 @@ "README.md" ], "scripts": { - "build": "rollup --config rollup.config.js", + "build": "yarn check-types && rollup --config rollup.config.js", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "test": "echo \"Warning: no test specified\"", "check-types": "tsc --noEmit --pretty",