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

LIME-1273 - Adding new call to personInfo endpoint #306

Merged
merged 1 commit into from
Oct 31, 2024
Merged

Conversation

ElliotMurphyGDS
Copy link
Contributor

What changed

  • Updated Root.js Controller to call new personInfo Endpoint and map returned values into sessionModel
  • made mapping of values to sessionModel conditional for compatibility with existing web route
  • Updated Config to include new personInfo endpoint path
  • Added tests for root controller

@ElliotMurphyGDS ElliotMurphyGDS requested a review from a team as a code owner October 29, 2024 09:07
};

//axios.post to new personInfo endpoint, put licence details into req.session.shared_claims shared claims
const personInfoApiResponse = await req.axios.post(
Copy link
Contributor

Choose a reason for hiding this comment

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

For security can we wrap this in an if statement with an env var so we can merge without triggering new code yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this actually means I can remove feature toggle from corresponding API PR

}
super.saveValues(req, res, next);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not still needed?

@@ -6,7 +6,8 @@ module.exports = {
PATHS: {
SESSION: "session",
CHECK: "check-driving-licence",
AUTHORIZATION: "authorization"
AUTHORIZATION: "authorization",
PERSON_INFO: "person-info"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct its different to whats on the ticket

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Endpoint on ticket was taken from a similar piece of work kiwi did so an internal decision not linked to any requirement, I opted to add the hyphen to keep inline with existing convention

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we update the ticket

it("should be an instance of BaseController", () => {
expect(root).to.be.an.instanceof(BaseController);
});

it("should retrieve shared_claims from session and store it in the journeyModel", async () => {
it("should retrieve shared_claims from session and store it in the sessionModel", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a negative check for if any of these values are absent

req.journeyModel.set("surname", sharedClaims.names[0]?.familyName);
req.journeyModel.set("givenNames", sharedClaims.names[0]?.givenNames);
}
let personInfoApiResponse = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

The should be within the if for the feature flag.

{ headers: headers }
);
}
if (personInfoApiResponse.data.drivingPermit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be in the above feature flag if.

It also needs to handle a failure of personInfoApiResponse not being returned and .data.drivingPermit not being present.

class RootController extends BaseController {
async saveValues(req, res, next) {
const sharedClaims = req.session?.shared_claims;
req.sessionModel.reset();
req.sessionModel.set("isAuthSourceRoute", false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to be resetting the session model we run the risk here of something failing and putting the user down a different route to the first one they were on if they navigate back

session_id: req.session?.tokenId
};

if (process.env.AUTH_SOURCE_ENABLED === "true") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be isAuthSourceRoute
if (process.env.AUTH_SOURCE_ENABLED && !isAuthSourceRoute)

That way we only run it once per journey

@ElliotMurphyGDS ElliotMurphyGDS force-pushed the LIME-1273 branch 11 times, most recently from 6a91151 to 186733e Compare October 31, 2024 10:41
personInfoApiResponse.data?.drivingPermit[0]?.expiryDate &&
personInfoApiResponse.data?.drivingPermit[0]?.issueDate &&
personInfoApiResponse.data?.drivingPermit[0]?.issuedBy &&
personInfoApiResponse.data?.drivingPermit[0]?.issueNumber &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be more complicated. For instance we only expect an issue number if its DVLA

}
}
super.saveValues(req, res, next);
}

async checkForValidSharedClaimsData(req, personInfoApiResponse) {
Copy link
Contributor

Choose a reason for hiding this comment

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

On naming can we make this return true or false and update the state in the calling method

Copy link

sonarcloud bot commented Oct 31, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
76.6% Coverage on New Code (required ≥ 80%)
2 New Code Smells (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@ElliotMurphyGDS ElliotMurphyGDS merged commit d294bf0 into main Oct 31, 2024
5 of 6 checks passed
@ElliotMurphyGDS ElliotMurphyGDS deleted the LIME-1273 branch October 31, 2024 19:19
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