[BACK-GOV-04] Development of soapHandler Business Logic and Database Integration

Backend: Logic

Published

October 14, 2026

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

  1. Incoming HTTP Request Validation: Within the soapHandler, enforce strict access restrictions—allow only the POST method. Extract the data bytes from r.Body using io.ReadAll and execute xml.Unmarshal into the request structure.
  2. System Token Verification (Logic Step 1): Write a parametrized SQL query against the service_access_tokens table. If the token is not found (sql.ErrNoRows) or the is_active field equals false, abort execution and return an ACCESS_DENIED: Invalid or suspended master token error wrapper.
  3. Fetching the Employee Profile (Logic Step 2): Implement a secure parameterized query via db.QueryRow targeted at the digital_employees table, passing a sanitized, lowercase, and trimmed representation of reqData.Email.
  4. 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", return profile.Authorized = false and append the GOV_ACCOUNT_BLOCKED error string.
    • Upon a successful lookup with an ACTIVE status, map profile.Authorized = true and append a SUCCESS status code.