Skip to content

Commit 47f82c2

Browse files
authored
orderflow-proxy should be able to register TLS cert (#62)
## 📝 Summary Fixes bug in #60, which disallowed orderflow-proxy to register
1 parent f64bd23 commit 47f82c2

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed

ports/http_handler.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -270,29 +270,15 @@ func (bhs *BuilderHubHandler) RegisterCredentials(w http.ResponseWriter, r *http
270270
return
271271
}
272272

273-
// Validate payload based on service type
274-
var tlsCert string
275-
var ecdsaPubkey []byte
273+
if sc.ECDSAPubkey == nil && sc.TLSCert == "" {
274+
http.Error(w, "No credentials provided", http.StatusBadRequest)
275+
return
276+
}
276277

277-
switch service {
278-
case "instance":
279-
if sc.TLSCert == "" {
280-
http.Error(w, "TLS cert is required for instance service", http.StatusBadRequest)
281-
return
282-
}
283-
tlsCert = sc.TLSCert
284-
case "orderflow_proxy", "rbuilder":
285-
if sc.ECDSAPubkey == nil {
286-
http.Error(w, "ECDSA pubkey is required for service", http.StatusBadRequest)
287-
return
288-
}
289-
ecdsaPubkey = sc.ECDSAPubkey.Bytes()
290-
default:
291-
if sc.TLSCert == "" && sc.ECDSAPubkey == nil {
292-
http.Error(w, "No credentials provided", http.StatusBadRequest)
293-
return
294-
}
295-
tlsCert = sc.TLSCert
278+
tlsCert := sc.TLSCert
279+
280+
var ecdsaPubkey []byte
281+
if sc.ECDSAPubkey != nil {
296282
ecdsaPubkey = sc.ECDSAPubkey.Bytes()
297283
}
298284

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,42 @@ jsonpath "$.[0].ip" == "1.2.3.4"
8585
jsonpath "$.[0].name" == "test_builder"
8686

8787
# [Builder API] Register credentials for 'rbuilder' service
88-
#POST http://localhost:8888/api/l1-builder/v1/register_credentials/rbuilder
89-
#{
90-
# "ecdsa_pubkey_address": "0x321f3426eEc20DE1910af1CD595c4DD83BEA0BA5"
91-
#}
88+
POST http://localhost:8888/api/l1-builder/v1/register_credentials/rbuilder
89+
{
90+
"ecdsa_pubkey_address": "0x321f3426eEc20DE1910af1CD595c4DD83BEA0BA5"
91+
}
92+
HTTP 200
9293

93-
## [Builder API] List of peers now includes the added credentials
94-
#GET http://localhost:8888/api/l1-builder/v1/builders
95-
#HTTP 200
96-
#[Asserts]
97-
#jsonpath "$.[0].rbuilder.ecdsa_pubkey_address" == "0x321f3426eec20de1910af1cd595c4dd83bea0ba5"
94+
# [Builder API] Register credentials for 'orderflow_proxy' service
95+
POST http://localhost:8888/api/l1-builder/v1/register_credentials/orderflow_proxy
96+
{
97+
"ecdsa_pubkey_address": "0x321f3426eEc20DE1910af1CD595c4DD83BEA0BA5",
98+
"tls_cert": "abcdefghijklmnopqrstuvwxyz"
99+
}
100+
HTTP 200
101+
102+
# [Builder API] Register credentials for 'instance' service
103+
POST http://localhost:8888/api/l1-builder/v1/register_credentials/instance
104+
{
105+
"tls_cert": "1234567890"
106+
}
107+
HTTP 200
108+
109+
# [Builder API] Register credentials for custom service
110+
POST http://localhost:8888/api/l1-builder/v1/register_credentials/foobar123
111+
{
112+
"tls_cert": "1234567890",
113+
"ecdsa_pubkey_address": "0x321f3426eEc20DE1910af1CD595c4DD83BEA0BA5"
114+
}
115+
HTTP 200
116+
117+
# [Builder API] Get the list of peers
118+
GET http://localhost:8888/api/l1-builder/v1/builders
119+
HTTP 200
120+
[Asserts]
121+
jsonpath "$.[0].orderflow_proxy.tls_cert" == "abcdefghijklmnopqrstuvwxyz"
122+
jsonpath "$.[0].orderflow_proxy.ecdsa_pubkey_address" == "0x321f3426eec20de1910af1cd595c4dd83bea0ba5"
123+
jsonpath "$.[0].rbuilder.ecdsa_pubkey_address" == "0x321f3426eec20de1910af1cd595c4dd83bea0ba5"
124+
jsonpath "$.[0].instance.tls_cert" == "1234567890"
125+
jsonpath "$.[0].foobar123.tls_cert" == "1234567890"
126+
jsonpath "$.[0].foobar123.ecdsa_pubkey_address" == "0x321f3426eec20de1910af1cd595c4dd83bea0ba5"

scripts/ci/integration-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ printf 'GET http://localhost:8888/\nHTTP 404' | hurl --retry 60 > /dev/null;
1616

1717
# Run the tests
1818
echo "Running integration tests..."
19-
hurl --test scripts/ci/setup.hurl
19+
hurl --test scripts/ci/e2e-test.hurl
2020
echo "Integration tests completed successfully."
2121

2222
# Stop and remove the Docker containers

0 commit comments

Comments
 (0)