[BACK-GOV-04] Development of soapHandler Business Logic and Database Integration
Backend: Logic
NoteTask Brief
- Repository / Component:
gov_identity_soap_mock. - Language: Go (1.27+).
- Task Type: Backend (Business Logic).
- Status: Ready for Implementation
Task Description
It is necessary to implement the soapHandler function, which will act as the primary controller: validating the request method, extracting the XML body, verifying gateway access privileges, and returning the employee’s status from the database.
Step-by-Step Instructions
- Incoming HTTP Request Validation: Within the
soapHandler, enforce strict access restrictions—allow only thePOSTmethod. Extract the data bytes fromr.Bodyusingio.ReadAlland executexml.Unmarshalinto the request structure. - System Token Verification (Logic Step 1): Write a parametrized SQL query against the
service_access_tokenstable. If the token is not found (sql.ErrNoRows) or theis_activefield equalsfalse, abort execution and return anACCESS_DENIED: Invalid or suspended master tokenerror wrapper. - Fetching the Employee Profile (Logic Step 2): Implement a secure parameterized query via
db.QueryRowtargeted at thedigital_employeestable, passing a sanitized, lowercase, and trimmed representation ofreqData.Email. - Implementing Test Scenarios and the Error Matrix:
- If the employee does not exist in the database, construct a response where
profile.ErrorMessage = "USER_NOT_FOUND". - If the employee is found but their status is
gov_status == "BLOCKED", returnprofile.Authorized = falseand append theGOV_ACCOUNT_BLOCKEDerror string. - Upon a successful lookup with an
ACTIVEstatus, mapprofile.Authorized = trueand append aSUCCESSstatus code.
- If the employee does not exist in the database, construct a response where