[ARVADOS-WORKBENCH2] updated: 2.1.0-141-ge2b8fc2b

Git user git at public.arvados.org
Wed Jan 6 21:13:39 UTC 2021


Summary of changes:
 src/store/collections/collection-info-actions.ts   |   2 -
 .../webdav-s3-dialog/webdav-s3-dialog.test.tsx     | 135 +++++++++++++++++++++
 .../webdav-s3-dialog/webdav-s3-dialog.tsx          |  21 ++--
 3 files changed, 146 insertions(+), 12 deletions(-)
 create mode 100644 src/views-components/webdav-s3-dialog/webdav-s3-dialog.test.tsx

       via  e2b8fc2b2f4eb4dde99dbbf7d060e5b7a6bb4e92 (commit)
      from  701db873d602c7f1ba414ebbbf07551892587055 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit e2b8fc2b2f4eb4dde99dbbf7d060e5b7a6bb4e92
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Wed Jan 6 16:13:13 2021 -0500

    16622: Add Enzyme tests for WebDavS3InfoDialog
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/src/store/collections/collection-info-actions.ts b/src/store/collections/collection-info-actions.ts
index 5b7154e2..49fe54f6 100644
--- a/src/store/collections/collection-info-actions.ts
+++ b/src/store/collections/collection-info-actions.ts
@@ -14,7 +14,6 @@ export interface WebDavS3InfoDialogData {
     token: string;
     downloadUrl: string;
     collectionsUrl: string;
-    homeCluster: string;
     localCluster: string;
     username: string;
     activeTab: number;
@@ -30,7 +29,6 @@ export const openWebDavS3InfoDialog = (uuid: string, activeTab?: number) =>
                 token: getState().auth.apiToken,
                 downloadUrl: getState().auth.config.keepWebServiceUrl,
                 collectionsUrl: getState().auth.config.keepWebInlineServiceUrl,
-                homeCluster: getState().auth.homeCluster,
                 localCluster: getState().auth.localCluster,
                 username: getState().auth.user!.username,
                 activeTab: activeTab || 0,
diff --git a/src/views-components/webdav-s3-dialog/webdav-s3-dialog.test.tsx b/src/views-components/webdav-s3-dialog/webdav-s3-dialog.test.tsx
new file mode 100644
index 00000000..dab324be
--- /dev/null
+++ b/src/views-components/webdav-s3-dialog/webdav-s3-dialog.test.tsx
@@ -0,0 +1,135 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { mount, configure, shallow } from 'enzyme';
+import * as Adapter from "enzyme-adapter-react-16";
+import { MuiThemeProvider, WithStyles } from '@material-ui/core';
+import { CustomTheme } from '~/common/custom-theme';
+import { WebDavS3InfoDialog, CssRules } from './webdav-s3-dialog';
+import { WithDialogProps } from '~/store/dialog/with-dialog';
+import { WebDavS3InfoDialogData, COLLECTION_WEBDAV_S3_DIALOG_NAME } from '~/store/collections/collection-info-actions';
+import { Provider } from "react-redux";
+import { createStore, combineReducers } from 'redux';
+import { configureStore, RootStore } from '~/store/store';
+import { createBrowserHistory } from "history";
+import { createServices } from "~/services/services";
+
+configure({ adapter: new Adapter() });
+
+describe('WebDavS3InfoDialog', () => {
+    let props: WithDialogProps<WebDavS3InfoDialogData> & WithStyles<CssRules>;
+    let store;
+
+    beforeEach(() => {
+        const initialDialogState = {
+            [COLLECTION_WEBDAV_S3_DIALOG_NAME]: {
+                open: true,
+                data: {
+                    uuid: "zzzzz-4zz18-b1f8tbldjrm8885",
+                    token: "v2/zzzzb-jjjjj-123123/xxxtokenxxx",
+                    downloadUrl: "https://download.example.com",
+                    collectionsUrl: "https://collections.example.com",
+                    localCluster: "zzzzz",
+                    username: "bobby",
+                    activeTab: 0,
+                    setActiveTab: (event: any, tabNr: number) => { }
+                }
+            }
+        };
+        const initialAuthState = {
+            localCluster: "zzzzz",
+            remoteHostsConfig: {},
+            sessions: {},
+        };
+        store = createStore(combineReducers({
+            dialog: (state: any = initialDialogState, action: any) => state,
+            auth: (state: any = initialAuthState, action: any) => state,
+        }));
+
+        props = {
+            classes: {
+                details: 'details',
+            }
+        };
+    });
+
+    it('render cyberduck tab', () => {
+        store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 0;
+        // when
+        const wrapper = mount(
+            <MuiThemeProvider theme={CustomTheme}>
+                <Provider store={store}>
+                    <WebDavS3InfoDialog {...props} />
+                </Provider>
+            </MuiThemeProvider>
+        );
+
+        // then
+        expect(wrapper.text()).toContain("davs://bobby@download.example.com/by_id/zzzzz-4zz18-b1f8tbldjrm8885");
+    });
+
+    it('render win/mac tab', () => {
+        store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 1;
+        // when
+        const wrapper = mount(
+            <MuiThemeProvider theme={CustomTheme}>
+                <Provider store={store}>
+                    <WebDavS3InfoDialog {...props} />
+                </Provider>
+            </MuiThemeProvider>
+        );
+
+        // then
+        expect(wrapper.text()).toContain("https://download.example.com/by_id/zzzzz-4zz18-b1f8tbldjrm8885");
+    });
+
+    it('render s3 tab with federated token', () => {
+        store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 2;
+        // when
+        const wrapper = mount(
+            <MuiThemeProvider theme={CustomTheme}>
+                <Provider store={store}>
+                    <WebDavS3InfoDialog {...props} />
+                </Provider>
+            </MuiThemeProvider>
+        );
+
+        // then
+        expect(wrapper.text()).toContain("Secret Keyv2_zzzzb-jjjjj-123123_xxxtokenxxx");
+    });
+
+    it('render s3 tab with local token', () => {
+        store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 2;
+        store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.token = "v2/zzzzz-jjjjj-123123/xxxtokenxxx";
+        // when
+        const wrapper = mount(
+            <MuiThemeProvider theme={CustomTheme}>
+                <Provider store={store}>
+                    <WebDavS3InfoDialog {...props} />
+                </Provider>
+            </MuiThemeProvider>
+        );
+
+        // then
+        expect(wrapper.text()).toContain("Access Keyzzzzz-jjjjj-123123Secret Keyxxxtokenxxx");
+    });
+
+    it('render cyberduck tab with wildcard DNS', () => {
+        store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.activeTab = 0;
+        store.getState().dialog[COLLECTION_WEBDAV_S3_DIALOG_NAME].data.collectionsUrl = "https://*.collections.example.com";
+        // when
+        const wrapper = mount(
+            <MuiThemeProvider theme={CustomTheme}>
+                <Provider store={store}>
+                    <WebDavS3InfoDialog {...props} />
+                </Provider>
+            </MuiThemeProvider>
+        );
+
+        // then
+        expect(wrapper.text()).toContain("davs://bobby@zzzzz-4zz18-b1f8tbldjrm8885.collections.example.com");
+    });
+
+});
diff --git a/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx b/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx
index 217f9a2a..018a0ef0 100644
--- a/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx
+++ b/src/views-components/webdav-s3-dialog/webdav-s3-dialog.tsx
@@ -10,7 +10,7 @@ import { WithDialogProps } from '~/store/dialog/with-dialog';
 import { compose } from 'redux';
 import { DetailsAttribute } from "~/components/details-attribute/details-attribute";
 
-type CssRules = 'details';
+export type CssRules = 'details';
 
 const styles: StyleRulesCallback<CssRules> = theme => ({
     details: {
@@ -57,18 +57,19 @@ export const WebDavS3InfoDialog = compose(
         } else {
             winDav = new URL(props.data.downloadUrl);
             cyberDav = new URL(props.data.downloadUrl);
-            winDav.pathname = `/by_id/${props.data.uuid}/`;
-            cyberDav.pathname = `/by_id/${props.data.uuid}/`;
+            winDav.pathname = `/by_id/${props.data.uuid}`;
+            cyberDav.pathname = `/by_id/${props.data.uuid}`;
         }
 
-        cyberDav.protocol = { "http:": "dav:", "https:": "davs:" }[cyberDav.protocol];
+        cyberDav.username = props.data.username;
+        const cyberDavStr = "dav" + cyberDav.toString().slice(4);
 
         const s3endpoint = new URL(props.data.collectionsUrl.replace(/\/\*(--[^.]+)?\./, "/"));
 
         const sp = props.data.token.split("/");
         let tokenUuid;
         let tokenSecret;
-        if (sp.length === 3 && sp[0] === "v2" && props.data.homeCluster === props.data.localCluster) {
+        if (sp.length === 3 && sp[0] === "v2" && sp[1].slice(0, 5) === props.data.localCluster) {
             tokenUuid = sp[1];
             tokenSecret = sp[2];
         } else {
@@ -97,12 +98,12 @@ export const WebDavS3InfoDialog = compose(
                     <Tab value={2} key="s3" label="S3 bucket" />
                 </Tabs>
 
-                <TabPanel index={0} value={activeTab}>
+                <TabPanel index={1} value={activeTab}>
                     <h2>Settings</h2>
 
                     <DetailsAttribute
                         label='Internet address'
-                        value={<a href={winDav.toString()}>{winDav.toString()}</a>}
+                        value={<a href={winDav.toString()} target="_blank">{winDav.toString()}</a>}
                         copyValue={winDav.toString()} />
 
                     <DetailsAttribute
@@ -129,11 +130,11 @@ export const WebDavS3InfoDialog = compose(
                     </ol>
                 </TabPanel>
 
-                <TabPanel index={1} value={activeTab}>
+                <TabPanel index={0} value={activeTab}>
                     <DetailsAttribute
                         label='Server'
-                        value={<a href={cyberDav.toString()}>{cyberDav.toString()}</a>}
-                        copyValue={cyberDav.toString()} />
+                        value={<a href={cyberDavStr} target="_blank">{cyberDavStr}</a>}
+                        copyValue={cyberDavStr} />
 
                     <DetailsAttribute
                         label='Username'

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list