Skip to content

Commit

Permalink
fix response headers xml
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac committed Nov 20, 2024
1 parent 92b307c commit 174711f
Show file tree
Hide file tree
Showing 8 changed files with 1,150 additions and 284 deletions.
309 changes: 168 additions & 141 deletions connector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@ func TestHTTPConnector_authentication(t *testing.T) {
"body": {
"name": "pet"
}
},
"fields": {
"type": "object",
"fields": {
"headers": {
"column": "headers",
"type": "column"
},
"response": {
"column": "response",
"type": "column"
}
}
}
}
],
Expand Down Expand Up @@ -288,19 +301,32 @@ func TestHTTPConnector_authentication(t *testing.T) {
},
"fields": {
"fields": {
"fields": {
"completed": {
"column": "completed",
"type": "column"
},
"status": {
"column": "status",
"type": "column"
}
"headers": {
"column": "headers",
"type": "column"
},
"type": "object"
"response": {
"column": "response",
"type": "column",
"fields": {
"type": "array",
"fields": {
"fields": {
"completed": {
"column": "completed",
"type": "column"
},
"status": {
"column": "status",
"type": "column"
}
},
"type": "object"
}
}
}
},
"type": "array"
"type": "object"
}
}
],
Expand All @@ -322,136 +348,137 @@ func TestHTTPConnector_authentication(t *testing.T) {
})
})

// t.Run("encoding-xml", func(t *testing.T) {
// reqBody := []byte(`{
// "operations": [
// {
// "type": "procedure",
// "name": "putPetXml",
// "arguments": {
// "body": {
// "id": 10,
// "name": "doggie",
// "category": {
// "id": 1,
// "name": "Dogs"
// },
// "photoUrls": ["string"],
// "tags": [
// {
// "id": 0,
// "name": "string"
// }
// ],
// "status": "available"
// }
// },
// "fields": {
// "fields": {
// "headers": {
// "column": "headers",
// "type": "column"
// },
// "response": {
// "column": "response",
// "fields": {
// "fields": {
// "category": {
// "column": "category",
// "fields": {
// "fields": {
// "id": {
// "column": "id",
// "type": "column"
// },
// "name": {
// "column": "name",
// "type": "column"
// }
// },
// "type": "object"
// },
// "type": "column"
// },
// "field": {
// "column": "field",
// "type": "column"
// },
// "id": {
// "column": "id",
// "type": "column"
// },
// "name": {
// "column": "name",
// "type": "column"
// },
// "photoUrls": {
// "column": "photoUrls",
// "type": "column"
// },
// "status": {
// "column": "status",
// "type": "column"
// },
// "tags": {
// "column": "tags",
// "fields": {
// "fields": {
// "fields": {
// "id": {
// "column": "id",
// "type": "column"
// },
// "name": {
// "column": "name",
// "type": "column"
// }
// },
// "type": "object"
// },
// "type": "array"
// },
// "type": "column"
// }
// },
// "type": "object"
// },
// "type": "column"
// }
// },
// "type": "object"
// }
// }
// ],
// "collection_relationships": {}
// }`)

// res, err := http.Post(fmt.Sprintf("%s/mutation", testServer.URL), "application/json", bytes.NewBuffer(reqBody))
// assert.NilError(t, err)
// assertHTTPResponse(t, res, http.StatusOK, schema.MutationResponse{
// OperationResults: []schema.MutationOperationResults{
// schema.NewProcedureResult(map[string]any{
// "headers": map[string]any{"Content-Type": string("application/xml")},
// "response": map[string]any{"headers": nil, "response": map[string]any{
// "id": int64(10),
// "name": "doggie",
// "category": map[string]any{
// "id": int64(1),
// "name": "Dogs",
// },
// "photoUrls": []any{"string"},
// "tags": []any{
// map[string]any{
// "id": int64(0),
// "name": "string",
// },
// },
// "status": "available",
// }},
// }).Encode(),
// },
// })
// })
t.Run("encoding-xml", func(t *testing.T) {
reqBody := []byte(`{
"operations": [
{
"type": "procedure",
"name": "putPetXml",
"arguments": {
"body": {
"id": 10,
"name": "doggie",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": ["string"],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
},
"fields": {
"fields": {
"headers": {
"column": "headers",
"type": "column"
},
"response": {
"column": "response",
"fields": {
"fields": {
"category": {
"column": "category",
"fields": {
"fields": {
"id": {
"column": "id",
"type": "column"
},
"name": {
"column": "name",
"type": "column"
}
},
"type": "object"
},
"type": "column"
},
"field": {
"column": "field",
"type": "column"
},
"id": {
"column": "id",
"type": "column"
},
"name": {
"column": "name",
"type": "column"
},
"photoUrls": {
"column": "photoUrls",
"type": "column"
},
"status": {
"column": "status",
"type": "column"
},
"tags": {
"column": "tags",
"fields": {
"fields": {
"fields": {
"id": {
"column": "id",
"type": "column"
},
"name": {
"column": "name",
"type": "column"
}
},
"type": "object"
},
"type": "array"
},
"type": "column"
}
},
"type": "object"
},
"type": "column"
}
},
"type": "object"
}
}
],
"collection_relationships": {}
}`)

res, err := http.Post(fmt.Sprintf("%s/mutation", testServer.URL), "application/json", bytes.NewBuffer(reqBody))
assert.NilError(t, err)
assertHTTPResponse(t, res, http.StatusOK, schema.MutationResponse{
OperationResults: []schema.MutationOperationResults{
schema.NewProcedureResult(map[string]any{
"headers": map[string]any{"Content-Type": string("application/xml")},
"response": map[string]any{
"id": float64(10),
"name": "doggie",
"category": map[string]any{
"id": float64(1),
"name": "Dogs",
},
"field": nil,
"photoUrls": []any{"string"},
"tags": []any{
map[string]any{
"id": float64(0),
"name": "string",
},
},
"status": "available",
},
}).Encode(),
},
})
})
}

func TestHTTPConnector_distribution(t *testing.T) {
Expand Down
Loading

0 comments on commit 174711f

Please sign in to comment.