Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PODS-9123: #216

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

PODS-9123: #216

wants to merge 3 commits into from

Conversation

PavelVjalicin
Copy link
Contributor

Code:

  • Added auth action which cross references data from the list of legacy schemes and legacy scheme details APIs. It checks whether a given PSA or PSA/PSTR combination has access to data for a scheme and uses the schemeName field, common to both responses, for matching purposes. If the schemeName doesn't match or other failures occur you will reach Page not found.
  • Removed unused custom exception

Code:
- Added auth action which cross references data from the list of legacy schemes and legacy scheme details APIs. It checks whether a given PSA or PSA/PSTR combination has access to data for a scheme and uses the schemeName field, common to both responses, for matching purposes. If the schemeName doesn't match or other failures occur you will reach Page not found.
- Removed unused custom exception
@PavelVjalicin PavelVjalicin marked this pull request as draft February 14, 2024 09:47
@platops-pr-bot
Copy link

Comment on lines 54 to 66
val futureMaybeListOfSchemesForPsa: Future[Option[List[Items]]] = listOfSchemes.flatMap {
case Right(list) => Future.successful(list.items)
case _ =>
logger.info("getListOfSchemes returned None for this PsaID")
Future.successful(None)
}

val futureSchemeDetailsForPsaWithPstr = legacySchemeDetails.flatMap {
case Right(data) => Future.successful(data.as[JsObject])
case _ =>
logger.info("getLegacySchemeDetails returned no data for this PsaId and PSTR")
Future.successful(Json.obj())
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need for flatMap here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using flatMap here to avoid nested futures of type Future[Future[Option[List[Items]]]] and Future[Future[JsObject]] respectively

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In all 4 outcomes of those you are choosing to return a future.
You don't have to.
Instead of Future.successful(list.items) return list.items

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in fb7768e

app/controllers/actions/PsaSchemeAuthAction.scala Outdated Show resolved Hide resolved
app/controllers/actions/PsaSchemeAuthAction.scala Outdated Show resolved Hide resolved
@PavelVjalicin
Copy link
Contributor Author

I will take a look at the actual authentication later today.

Code:
- Added type annotations
- Changed comparison of String results in for comprehension
- Added logger statements
- General formatting
@platops-pr-bot
Copy link

@PavelVjalicin
Copy link
Contributor Author

For authentication we want to just send a request to get legacy scheme details 1815. If it responds it's authenticated if not it's not authenticated. We also want to log any non 2xx responses from get legacy scheme details.
It's unclear what kind of response we will receive from IF when calling this while not being authenticated, need to figure that out and filter out logging for that response.

Code:
- Fixed scalastyle complaints
- Removed calls to list of schemes API
- Added logging for when call to getLegacySchemeDetails fails
- General refactoring
- Added test for auth actions
@PavelVjalicin
Copy link
Contributor Author

Looks good Nathan. Let's confirm with the people who provide us with the API that this works and how to recover from failure.

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.

3 participants