From 3e19e1b9a020b085f45056395d586bfdb7d51ecf Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Mon, 8 Jan 2024 18:07:33 +0100 Subject: Make sure the gandi livedns API is accessed with POST or PUT --- guile/email-key-rotation/dns.scm | 2 ++ guile/email-key-rotation/gandi.scm | 6 +++++- guile/email-key-rotation/tests/fake-gandi-livedns.scm | 10 +++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/guile/email-key-rotation/dns.scm b/guile/email-key-rotation/dns.scm index 65dd75a..620a916 100644 --- a/guile/email-key-rotation/dns.scm +++ b/guile/email-key-rotation/dns.scm @@ -59,6 +59,7 @@ gandi-configuration (gandi:domain gandi-configuration) path-under-domain + #:method 'POST #:headers headers #:body body #:http-request http-request) @@ -69,6 +70,7 @@ gandi-configuration (gandi:domain gandi-configuration) path-under-domain + #:method 'PUT #:headers headers #:body body #:http-request http-request) diff --git a/guile/email-key-rotation/gandi.scm b/guile/email-key-rotation/gandi.scm index 2f89785..ae9cc84 100644 --- a/guile/email-key-rotation/gandi.scm +++ b/guile/email-key-rotation/gandi.scm @@ -27,6 +27,7 @@ domain path-under-domain #:key + (method 'GET) (headers '()) (body #f) (http-request http-request)) @@ -66,7 +67,10 @@ `((Authorization . ,(string-append "ApiKey " (api-key configuration))) ,@headers))) - (http-request uri #:headers headers #:body body))))) + (http-request uri + #:method method + #:headers headers + #:body body))))) (define (sxml->configuration sxml) (with-exception-handler diff --git a/guile/email-key-rotation/tests/fake-gandi-livedns.scm b/guile/email-key-rotation/tests/fake-gandi-livedns.scm index 4e2df13..4a183ce 100644 --- a/guile/email-key-rotation/tests/fake-gandi-livedns.scm +++ b/guile/email-key-rotation/tests/fake-gandi-livedns.scm @@ -15,7 +15,15 @@ #:duplicates (merge-generics)) (define (fake-http-request expected-domain expected-api-key log-port) - (lambda* (uri #:key headers body) + (lambda* (uri #:key method headers body) + (unless (or (equal? method 'POST) + (equal? method 'PUT)) + (raise-exception + (make-exception + (make-error) + (make-exception-with-irritants (list method)) + (make-exception-with-message + "Gandi method is neither POST nor PUT")))) (unless (equal? (uri-scheme uri) 'https) (raise-exception (make-exception -- cgit v1.2.3