Skip to content

feat: SOAP codec for KAS-API envelope - #24

Merged
chmmou merged 1 commit into
mainfrom
feature/soap-codec
May 3, 2026
Merged

feat: SOAP codec for KAS-API envelope#24
chmmou merged 1 commit into
mainfrom
feature/soap-codec

Conversation

@chmmou

@chmmou chmmou commented May 3, 2026

Copy link
Copy Markdown
Owner

SOAP codec for KAS-API responses and requests.

  • internal/soap.Value: discriminated union over xsi:type (string/int/float/boolean, ns2:Map, SOAP-ENC:Array). Map preserves insertion order.
  • internal/soap.Decode: parses a KasApiResponse envelope; returns *Response on success or *FaultError on SOAP-ENV:Fault.
  • internal/soap.EncodeRequest: builds the JSON-in-<Params> request envelope with required-field validation.

Table-driven tests cover 471 response fixtures across testdata/ plus shape pins (get_accounts, get_server_information, fault detail, empty array) and encoder validation. testdata/session/ is left for the KasAuth client (issue #5).

stdlib-only (encoding/xml + encoding/json); no third-party SOAP library — none of the maintained Go SOAP libs handle the Apache xml-soap ns2:Map discriminator shape, and the request side is a JSON blob inside an XML element.

Closes #3.

… encoder)

Closes #3.

internal/soap exposes:

- Value: discriminated union over xsi:type (string/int/float/boolean,
  ns2:Map, SOAP-ENC:Array). Map preserves insertion order via []KV.
- Decode: parses a KasApi SOAP envelope; returns *Response on success
  and *FaultError on SOAP-ENV:Fault.
- Response.Body exposes typed shortcuts (KasFloodDelay, ReturnString,
  ReturnInfo, Msg) and the full ordered Raw map.
- EncodeRequest: serializes a typed Request as JSON inside the
  <tns:KasApi><Params> envelope; json.Marshal HTML-escapes <, > and &
  so the body is always XML-safe.

Tests are table-driven over every response fixture under testdata/
(471 files), dispatched by content: envelopes containing SOAP-ENV:Fault
must surface as *FaultError, others must decode into a populated
Response. testdata/session/ is excluded — those are KasAuth responses
covered by issue #5.

Notable real-world quirks pinned by tests:
- testdata/ftpuser/get_ftpuser_response_failed_empty_list.xml is named
  "failed" but is a success envelope with empty ReturnInfo array;
  testdata/ddns/get_ddnsusers_response_failed_empty_list.xml for the
  same logical case is a Fault. KAS is inconsistent here.
@chmmou
chmmou merged commit 6edce5a into main May 3, 2026
1 check passed
@chmmou
chmmou deleted the feature/soap-codec branch May 3, 2026 09:51
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.

SOAP transport: ns2:Map codec

1 participant