[ARVADOS-WORKBENCH2] updated: 1.2.0-916-g13bf073

Git user git at public.curoverse.com
Wed Nov 21 05:14:51 EST 2018


Summary of changes:
 .../authorized-keys-service.ts                     | 24 ++++++++++++++++++++--
 .../common-service/common-resource-service.ts      |  6 ------
 src/store/auth/auth-action.ts                      | 16 +++++++--------
 3 files changed, 30 insertions(+), 16 deletions(-)

       via  13bf073c77ca9fcf75ebd31098a9bf538e96c9c9 (commit)
      from  42db83a0075f9704dcbfb2cd29821c97ff0fe34b (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 13bf073c77ca9fcf75ebd31098a9bf538e96c9c9
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date:   Wed Nov 21 11:14:45 2018 +0100

    move ssh errors from common resource to auth keys service
    
    Feature #14479_ssh_keys
    
    Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>

diff --git a/src/services/authorized-keys-service/authorized-keys-service.ts b/src/services/authorized-keys-service/authorized-keys-service.ts
index b51704a..c952f42 100644
--- a/src/services/authorized-keys-service/authorized-keys-service.ts
+++ b/src/services/authorized-keys-service/authorized-keys-service.ts
@@ -4,11 +4,31 @@
 
 import { AxiosInstance } from "axios";
 import { SshKeyResource } from '~/models/ssh-key';
-import { CommonResourceService } from "~/services/common-service/common-resource-service";
+import { CommonResourceService, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
 import { ApiActions } from "~/services/api/api-actions";
 
+export enum AuthorizedKeysServiceError {
+    UNIQUE_PUBLIC_KEY = 'UniquePublicKey',
+    INVALID_PUBLIC_KEY = 'InvalidPublicKey',
+}
+
 export class AuthorizedKeysService extends CommonResourceService<SshKeyResource> {
     constructor(serverApi: AxiosInstance, actions: ApiActions) {
         super(serverApi, "authorized_keys", actions);
     }
-}
\ No newline at end of file
+}
+
+export const getAuthorizedKeysServiceError = (errorResponse: any) => {
+    if ('errors' in errorResponse && 'errorToken' in errorResponse) {
+        const error = errorResponse.errors.join('');
+        switch (true) {
+            case /Public key does not appear to be a valid ssh-rsa or dsa public key/.test(error):
+                return AuthorizedKeysServiceError.INVALID_PUBLIC_KEY;
+            case /Public key already exists in the database, use a different key./.test(error):
+                return AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY;
+            default:
+                return CommonResourceServiceError.UNKNOWN;
+        }
+    }
+    return CommonResourceServiceError.NONE;
+};
\ No newline at end of file
diff --git a/src/services/common-service/common-resource-service.ts b/src/services/common-service/common-resource-service.ts
index 02a3379..70c1df0 100644
--- a/src/services/common-service/common-resource-service.ts
+++ b/src/services/common-service/common-resource-service.ts
@@ -35,8 +35,6 @@ export enum CommonResourceServiceError {
     UNIQUE_VIOLATION = 'UniqueViolation',
     OWNERSHIP_CYCLE = 'OwnershipCycle',
     MODIFYING_CONTAINER_REQUEST_FINAL_STATE = 'ModifyingContainerRequestFinalState',
-    UNIQUE_PUBLIC_KEY = 'UniquePublicKey',
-    INVALID_PUBLIC_KEY = 'InvalidPublicKey',
     UNKNOWN = 'Unknown',
     NONE = 'None'
 }
@@ -152,10 +150,6 @@ export const getCommonResourceServiceError = (errorResponse: any) => {
                 return CommonResourceServiceError.OWNERSHIP_CYCLE;
             case /Mounts cannot be modified in state 'Final'/.test(error):
                 return CommonResourceServiceError.MODIFYING_CONTAINER_REQUEST_FINAL_STATE;
-            case /Public key does not appear to be a valid ssh-rsa or dsa public key/.test(error):
-                return CommonResourceServiceError.INVALID_PUBLIC_KEY;
-            case /Public key already exists in the database, use a different key./.test(error):
-                return CommonResourceServiceError.UNIQUE_PUBLIC_KEY;
             default:
                 return CommonResourceServiceError.UNKNOWN;
         }
diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts
index 1a4ba0c..00e372a 100644
--- a/src/store/auth/auth-action.ts
+++ b/src/store/auth/auth-action.ts
@@ -5,15 +5,15 @@
 import { ofType, unionize, UnionOf } from '~/common/unionize';
 import { Dispatch } from "redux";
 import { reset, stopSubmit } from 'redux-form';
-import { User } from "~/models/user";
-import { RootState } from "../store";
-import { ServiceRepository } from "~/services/services";
-import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
 import { AxiosInstance } from "axios";
+import { RootState } from "../store";
 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 import { dialogActions } from '~/store/dialog/dialog-actions';
+import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
+import { ServiceRepository } from "~/services/services";
+import { getAuthorizedKeysServiceError, AuthorizedKeysServiceError } from '~/services/authorized-keys-service/authorized-keys-service';
 import { SshKeyCreateFormDialogData, KeyType, SshKeyResource } from '~/models/ssh-key';
-import { setBreadcrumbs } from '../breadcrumbs/breadcrumbs-actions';
+import { User } from "~/models/user";
 
 export const authActions = unionize({
     SAVE_API_TOKEN: ofType<string>(),
@@ -101,10 +101,10 @@ export const createSshKey = (data: SshKeyCreateFormDialogData) =>
                 hideDuration: 2000
             }));
         } catch (e) {
-            const error = getCommonResourceServiceError(e);
-            if (error === CommonResourceServiceError.UNIQUE_PUBLIC_KEY) {
+            const error = getAuthorizedKeysServiceError(e);
+            if (error === AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY) {
                 dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' }));
-            } else if (error === CommonResourceServiceError.INVALID_PUBLIC_KEY) {
+            } else if (error === AuthorizedKeysServiceError.INVALID_PUBLIC_KEY) {
                 dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' }));
             }
         }

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list