Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
trholdridge committed Nov 15, 2024
1 parent f094494 commit 64658fa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions integration-tests/utils/integration-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ const waitForAccessToWorkspaceBucket = async ({ page, billingProject, workspaceN
async ({ billingProject, workspaceName, timeout }) => {
console.info('waitForAccessToWorkspaceBucket ...');
const {
workspace: { googleProject, bucketName },
workspace: { googleProject },
} = await window.Ajax().Workspaces.workspace(billingProject, workspaceName).details(['workspace', 'azureContext']);

const startTime = Date.now();

const checks = [
// Get bucket metadata
() => window.Ajax().Buckets.checkBucketLocation(googleProject, bucketName),
() => window.Ajax().Buckets.checkBucketLocation(googleProject),
// https://rawls.dsde-dev.broadinstitute.org/#/workspaces/readBucket
// Checks if user has bucket access, 403 if not.
// This API checks if user has all expected permissions. `read` on API name does not accurately describe APIs functionality.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const LaunchAnalysisModal = ({
entityMetadata,
workspace,
workspace: {
workspace: { namespace, name: workspaceName, bucketName, googleProject },
workspace: { namespace, name: workspaceName, googleProject },
},
processSingle,
entitySelectionModel: { type, selectedEntities, newSetName },
Expand Down Expand Up @@ -50,9 +50,7 @@ const LaunchAnalysisModal = ({

useOnMount(() => {
const loadBucketLocation = withErrorReporting('Error loading bucket location')(async () => {
const { location, locationType } = await Ajax(signal)
.Workspaces.workspace(namespace, workspaceName)
.checkBucketLocation(googleProject, bucketName);
const { location, locationType } = await Ajax(signal).Workspaces.workspace(namespace, workspaceName).checkBucketLocation(googleProject);
setBucketLocation({ location, locationType });
});

Expand Down
5 changes: 2 additions & 3 deletions src/workspaces/NewWorkspaceModal/NewWorkspaceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { AzureStorage } from 'src/libs/ajax/AzureStorage';
import { Billing } from 'src/libs/ajax/billing/Billing';
import { resolveWdsApp } from 'src/libs/ajax/data-table-providers/WdsDataTableProvider';
import { FirecloudBucket } from 'src/libs/ajax/firecloud/FirecloudBucket';
import { Groups } from 'src/libs/ajax/Groups';
import { CurrentUserGroupMembership } from 'src/libs/ajax/Groups';
import { CurrentUserGroupMembership, Groups } from 'src/libs/ajax/Groups';
import { Apps } from 'src/libs/ajax/leonardo/Apps';
import { ListAppItem } from 'src/libs/ajax/leonardo/models/app-models';
import { Metrics } from 'src/libs/ajax/Metrics';
Expand Down Expand Up @@ -290,7 +289,7 @@ export const NewWorkspaceModal = withDisplayName(
isGoogleWorkspace(cloneWorkspace) &&
Workspaces(signal)
.workspace(namespace!, cloneWorkspace.workspace.name)
.checkBucketLocation(cloneWorkspace.workspace.googleProject, cloneWorkspace.workspace.bucketName)
.checkBucketLocation(cloneWorkspace.workspace.googleProject)
.then(({ location }) => {
// For current phased regionality release, we only allow US or NORTHAMERICA-NORTHEAST1 (Montreal) workspace buckets.
setBucketLocation(isSupportedBucketLocation(location) ? location : defaultLocation);
Expand Down
13 changes: 8 additions & 5 deletions src/workspaces/common/state/useWorkspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,17 @@ describe('useWorkspace', () => {
// remove workspaceInitialized because the server response does not include this information
const { workspaceInitialized, ...serverWorkspaceResponse } = initializedGoogleWorkspace;

// Throw error from checkBucketReadAccess
// Throw error from checkBucketLocation
asMockedFn(Workspaces).mockReturnValue(
partial<WorkspacesAjaxContract>({
workspace: () =>
partial<WorkspaceContract>({
details: jest.fn().mockResolvedValue(serverWorkspaceResponse),
checkBucketReadAccess: () => Promise.reject(new Response('Mock requester pays error', { status: 500 })),
checkBucketReadAccess: jest.fn(),
storageCostEstimate: jest.fn(),
bucketUsage: jest.fn(),
checkBucketLocation: () =>
Promise.reject(new Response('User must have access to user project', { status: 400 })),
}),
})
);
Expand All @@ -482,13 +486,13 @@ describe('useWorkspace', () => {
{
googleBucketLocation: defaultGoogleBucketOptions.googleBucketLocation,
googleBucketType: defaultGoogleBucketOptions.googleBucketType,
fetchedGoogleBucketLocation: 'ERROR',
fetchedGoogleBucketLocation: 'RPERROR',
},
defaultAzureStorageOptions
);

// Act
// Wait for the call to checkBucketReadAccess to execute
// Wait for the call to checkBucketLocation to execute
const { result } = await renderHookInAct(() => useWorkspace('testNamespace', 'testName'));

// Assert
Expand All @@ -497,7 +501,6 @@ describe('useWorkspace', () => {
expect(recentlyViewedWorkspaces.updateRecentlyViewedWorkspaces).toHaveBeenCalledWith(
initializedGoogleWorkspace.workspace.workspaceId
);
expect(GoogleStorage.saToken).toHaveBeenCalled();
});

it('can read workspace details from server, and poll WSM until the container exists', async () => {
Expand Down

0 comments on commit 64658fa

Please sign in to comment.