summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2021-06-29 21:11:21 +0200
committerRicardo Wurmus <rekado@elephly.net>2021-06-29 21:11:21 +0200
commit4ac2646e10ab9af196ca9b025c13cb056d99b1f6 (patch)
tree321dc43b6e54a1f0399e50ba0a521439a5096950
parent5b53bf56761a765efb0012aa6f10d854d8dfa9eb (diff)
tests: Add the most basic of tests for request signing.
-rw-r--r--Makefile.am1
-rw-r--r--tests/request.scm41
2 files changed, 42 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 2c50d9a..8cd93b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,6 +50,7 @@ SOURCES = $(GUILE_SOURCES) $(JSON_SOURCES)
TEST_EXTENSIONS = .scm
SCM_TESTS = \
+ tests/request.scm \
tests/serialize.scm
TESTS = $(SCM_TESTS)
diff --git a/tests/request.scm b/tests/request.scm
new file mode 100644
index 0000000..a9234f7
--- /dev/null
+++ b/tests/request.scm
@@ -0,0 +1,41 @@
+;;; guile-aws --- Scheme DSL for the AWS APIs
+;;; Copyright © 2021 Ricardo Wurmus <rekado@elephly.net>
+;;;
+;;; Guile-AWS is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published
+;;; by the Free Software Foundation, either version 3 of the License,
+;;; or (at your option) any later version.
+;;;
+;;; Guile-AWS is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (test-request)
+ #:use-module (aws request)
+ #:use-module (aws api ec2-2016-11-15)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-64))
+
+(test-begin "request")
+
+(test-assert "sign-headers: adds x-amz-date and authorization headers"
+ (let* ((headers
+ (filter cdr `((content-type . (application/x-www-form-urlencoded
+ (charset . "utf-8")))
+ (host . ("http://localhost" . #f))
+ (x-amz-target . #false))))
+ (signed (sign-headers headers
+ #:canonical-uri ""
+ #:service-name "s3"
+ #:payload-hash "abcdefg"
+ #:secret-key "SECRET_ABCDEFG"
+ #:access-key "ACCESS_ABCDEFG")))
+ (and (assoc-ref signed 'x-amz-date)
+ (assoc-ref signed 'authorization))))
+
+(test-end "request")