Skip to content

Conversation

@htranho
Copy link
Contributor

@htranho htranho commented Dec 2, 2025

Overview

What is the feature?

Check for assurance level 4 and role for non NASA MMT access

What is the Solution?

Check for assurance level 4 and role for non NASA MMT access

What areas of the application does this impact?

Non NASA MMT (Draft MMT)

Testing

Assurance level has to be '4' and ACL has 'name' containing NON_NASA_DRAFT_USER. Error pages for level less than 4 or level 4 but no role assigned.

Attachments

Checklist

  • I have added automated tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@htranho htranho marked this pull request as draft December 2, 2025 17:03
@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (MMT-3759@0ac94dd). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             MMT-3759    #1429   +/-   ##
===========================================
  Coverage            ?   98.19%           
===========================================
  Files               ?      433           
  Lines               ?     7082           
  Branches            ?     1519           
===========================================
  Hits                ?     6954           
  Misses              ?      127           
  Partials            ?        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@htranho htranho marked this pull request as ready for review December 2, 2025 17:32
throw new Error(`HTTP error! status: ${response.status}`)
}

const data = await response.json()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data.items isn't guaranteed to exist, can we default items to [] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const ErrorUnauthorizedAccess = () => {
const location = useLocation()
const queryParams = new URLSearchParams(location.search)
const errorType = queryParams.get('errorType') || 'default'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the ?errorType=foo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

<AuthContext.Provider value={context}>
<MemoryRouter initialEntries={[`/unauthorized?errorType=${errorType}`]}>
<Routes>
<Route path="/unauthorized" element={<ErrorUnauthorizedAccess />} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should match the route name to actual name in the implementation, unauthorizedAccess

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

}
}

if (assuranceLevel === 4) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const response = await edlCallback(mockEvent)

expect(response.statusCode).toBe(303)
expect(response.headers.Location).toBe('https://mmt.example.com/unauthorizedAccess?errorType=nonNasaMMT')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below this,
expect(checkNonNasaMMTAccess).toHaveBeenCalledTimes(1)

Anywhere in this file where you have a .toHAveBeenCalledWith(), there should be an accompanying .toHaveBeenCalledTimes()


await expect(checkNonNasaMMTAccess('testUser', 'testToken')).rejects.toThrow('Network error')
expect(consoleSpy).toHaveBeenCalledWith('Error checking Non-NASA MMT access:', expect.any(Error))
consoleSpy.mockRestore()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants