From 4ac2646e10ab9af196ca9b025c13cb056d99b1f6 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 29 Jun 2021 21:11:21 +0200 Subject: tests: Add the most basic of tests for request signing. --- Makefile.am | 1 + tests/request.scm | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/request.scm 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 +;;; +;;; 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 +;;; . + +(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") -- cgit v1.2.3