• Stars
    star
    699
  • Rank 62,101 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple mock implementation of the AWS S3 API startable as Docker image, TestContainer, JUnit 4 rule, JUnit Jupiter extension or TestNG listener

Latest Version Docker Hub Maven Build Java17 Kotlin Docker Pulls GitHub stars OpenSSF Best Practices OpenSSF Scorecard

S3Mock

S3Mock is a lightweight server that implements parts of the Amazon S3 API.
It has been created to support local integration testing by reducing infrastructure dependencies.

The S3Mock server can be started as a standalone Docker container, using Testcontainers, JUnit4, JUnit5 and TestNG support, or programmatically.

Changelog

See GitHub releases.
See also the changelog for detailed information about changes in releases and changes planned for future releases.

Supported S3 operations

Of these operations of the Amazon S3 API, all marked βœ… are supported by S3Mock:

Operation Support Comment
AbortMultipartUpload βœ…
CompleteMultipartUpload βœ…
CopyObject βœ…
CreateBucket βœ…
CreateMultipartUpload βœ…
DeleteBucket βœ…
DeleteBucketAnalyticsConfiguration ❌
DeleteBucketCors ❌
DeleteBucketEncryption ❌
DeleteBucketIntelligentTieringConfiguration ❌
DeleteBucketInventoryConfiguration ❌
DeleteBucketLifecycle βœ…
DeleteBucketMetricsConfiguration ❌
DeleteBucketOwnershipControls ❌
DeleteBucketPolicy ❌
DeleteBucketReplication ❌
DeleteBucketTagging ❌
DeleteBucketWebsite ❌
DeleteObject βœ…
DeleteObjects βœ…
DeleteObjectTagging ❌
DeletePublicAccessBlock ❌
GetBucketAccelerateConfiguration ❌
GetBucketAcl ❌
GetBucketAnalyticsConfiguration ❌
GetBucketCors ❌
GetBucketEncryption ❌
GetBucketIntelligentTieringConfiguration ❌
GetBucketInventoryConfiguration ❌
GetBucketLifecycle ❌ Deprecated in S3 API
GetBucketLifecycleConfiguration βœ…
GetBucketLocation βœ…
GetBucketLogging ❌
GetBucketMetricsConfiguration ❌
GetBucketNotification ❌
GetBucketNotificationConfiguration ❌
GetBucketOwnershipControls ❌
GetBucketPolicy ❌
GetBucketPolicyStatus ❌
GetBucketReplication ❌
GetBucketRequestPayment ❌
GetBucketTagging ❌
GetBucketVersioning ❌
GetBucketWebsite ❌
GetObject βœ…
GetObjectAcl βœ…
GetObjectAttributes βœ… for objects, not parts
GetObjectLegalHold βœ…
GetObjectLockConfiguration βœ…
GetObjectRetention βœ…
GetObjectTagging βœ…
GetObjectTorrent ❌
GetPublicAccessBlock ❌
HeadBucket βœ…
HeadObject βœ…
ListBucketAnalyticsConfigurations ❌
ListBucketIntelligentTieringConfigurations ❌
ListBucketInventoryConfigurations ❌
ListBucketMetricsConfigurations ❌
ListBuckets βœ…
ListMultipartUploads βœ…
ListObjects βœ… Deprecated in S3 API
ListObjectsV2 βœ…
ListObjectVersions ❌
ListParts βœ…
PutBucketAccelerateConfiguration ❌
PutBucketAcl ❌
PutBucketAnalyticsConfiguration ❌
PutBucketCors ❌
PutBucketEncryption ❌
PutBucketIntelligentTieringConfiguration ❌
PutBucketInventoryConfiguration ❌
PutBucketLifecycle ❌ Deprecated in S3 API
PutBucketLifecycleConfiguration βœ…
PutBucketLogging ❌
PutBucketMetricsConfiguration ❌
PutBucketNotification ❌
PutBucketNotificationConfiguration ❌
PutBucketOwnershipControls ❌
PutBucketPolicy ❌
PutBucketReplication ❌
PutBucketRequestPayment ❌
PutBucketTagging ❌
PutBucketVersioning ❌
PutBucketWebsite ❌
PutObject βœ…
PutObjectAcl βœ…
PutObjectLegalHold βœ…
PutObjectLockConfiguration βœ…
PutObjectRetention βœ…
PutObjectTagging βœ…
PutPublicAccessBlock ❌
RestoreObject ❌
SelectObjectContent ❌
UploadPart βœ…
UploadPartCopy βœ…
WriteGetObjectResponse ❌

File System Structure

S3Mock stores Buckets, Objects, Parts and other data on disk.
This lets users inspect the stored data while the S3Mock is running.
If the config property retainFilesOnExit is set to true, this data will not be deleted when S3Mock is shut down.

❗ FYI
While it may be possible to start S3Mock on a root folder from a previous run and have all data available through the S3 API, the structure and contents of the files are not considered Public API, and are subject to change in later releases.
Also, there are no automated test cases for this behaviour.

Root-Folder

S3Mock stores buckets and objects a root-folder.

This folder is expected to be empty when S3Mock starts. See also FYI above.

/<root-folder>/

Buckets

Buckets are stored as a folder with their name as created through the S3 API directly below the root:

/<root-folder>/<bucket-name>/

BucketMetadata is stored in a file in the bucket directory, serialized as JSON.
BucketMetadata contains the "key" -> "uuid" dictionary for all objects uploaded to this bucket among other data.

/<root-folder>/<bucket-name>/bucketMetadata.json

Objects

Objects are stored in folders below the bucket they were created in. A folder is created that uses the Object's UUID assigned in the BucketMetadata as a name.

/<root-folder>/<bucket-name>/<uuid>/

Object data is stored below that UUID folder.

Binary data is always stored in a file binaryData

/<root-folder>/<bucket-name>/<uuid>/binaryData

Object metadata is serialized as JSON and stored as objectMetadata.json

/<root-folder>/<bucket-name>/<uuid>/objectMetadata.json

Object ACL is serialized as XML and stored as objectAcl.xml

/<root-folder>/<bucket-name>/<uuid>/objectAcl.xml

Multipart Uploads

Multipart Uploads are created in a bucket using object keys and an uploadId.
The object is assigned a UUID within the bucket (stored in BucketMetadata).
The Multipart upload metadata is currently not stored on disk.

The parts folder is created below the object UUID folder named with the uploadId:

/<root-folder>/<bucket-name>/<uuid>/<uploadId>/

Each part is stored in the parts folder with the partNo as name and .part as a suffix.

/<root-folder>/<bucket-name>/<uuid>/<uploadId>/<partNo>.part

Usage

Configuration

The mock can be configured with the following environment variables:

  • validKmsKeys: list of KMS Key-Refs that are to be treated as valid.
    • KMS keys must be configured as valid ARNs in the format of "arn:aws:kms:region:acct-id:key/key-id", for example "arn:aws:kms:us-east-1:1234567890:key/valid-test-key-id"
    • The list must be comma separated keys like arn-1, arn-2
    • When requesting with KMS encryption, the key ID is passed to the SDK / CLI, in the example above this would be "valid-test-key-id".
    • S3Mock does not implement KMS encryption, if a key ID is passed in a request, S3Mock will just validate if a given Key was configured during startup and reject the request if the given Key was not configured.
  • initialBuckets: list of names for buckets that will be available initially.
    • The list must be comma separated names like bucketa, bucketb
  • root: the base directory to place the temporary files exposed by the mock.
  • debug: set to true to enable Spring Boot's debug output.
  • trace: set to true to enable Spring Boot's trace output.
  • retainFilesOnExit: set to true to let S3Mock keep all files that were created during its lifetime. Default is false, all files are removed if S3Mock shuts down.

S3Mock Docker

The S3Mock Docker container is the recommended way to use S3Mock.
It is released to Docker Hub.
The container is lightweight, built on top of the official Linux Alpine image.

If needed, configure memory and cpu limits for the S3Mock docker container.

The JVM will automatically use half the available memory.

Start using the command-line

Starting on the command-line:

docker run -p 9090:9090 -p 9191:9191 -t adobe/s3mock

The port 9090 is for HTTP, port 9191 is for HTTPS.

Example with configuration via environment variables:

docker run -p 9090:9090 -p 9191:9191 -e initialBuckets=test -e debug=true -t adobe/s3mock

Start using the Fabric8 Docker-Maven-Plugin

Our integration tests are using the Amazon S3 Client to verify the server functionality against the S3Mock. During the Maven build, the Docker image is started using the docker-maven-plugin and the corresponding ports are passed to the JUnit test through the maven-failsafe-plugin. See BucketV2IT as an example on how it's used in the code.

This way, one can easily switch between calling the S3Mock or the real S3 endpoint and this doesn't add any additional Java dependencies to the project.

Start using Testcontainers

The S3MockContainer is a Testcontainer implementation that comes pre-configured exposing HTTP and HTTPS ports. Environment variables can be set on startup.

The example S3MockContainerJupiterTest demonstrates the usage with JUnit 5. The example S3MockContainerManualTest demonstrates the usage with plain Java.

Testcontainers provides integrations for JUnit 4, JUnit 5 and Spock.
For more information, visit the Testcontainers website.

To use the S3MockContainer, use the following Maven artifact in test scope:

<dependency>
 <groupId>com.adobe.testing</groupId>
 <artifactId>s3mock-testcontainers</artifactId>
 <version>...</version>
 <scope>test</scope>
</dependency>

S3Mock Java

S3Mock Java libraries are released and published to the Sonatype Maven Repository and subsequently published to the official Maven mirrors.

⚠️ WARNING
Using the Java libraries is discouraged, see explanation below
Using the Docker image is encouraged to insulate both S3Mock and your application at runtime.

S3Mock is built using Spring Boot, if projects use S3Mock by adding the dependency to their project and starting the S3Mock during a JUnit test, classpaths of the tested application and of the S3Mock are merged, leading to unpredictable and undesired effects such as class conflicts or dependency version conflicts.
This is especially problematic if the tested application itself is a Spring (Boot) application, as both applications will load configurations based on availability of certain classes in the classpath, leading to unpredictable runtime behaviour.

This is the opposite of what software engineers are trying to achieve when thoroughly testing code in continuous integration...

S3Mock dependencies are updated regularly, any update could break any number of projects.
See also issues labelled "dependency-problem".

See also the Java section below

Start using the JUnit4 Rule

The example S3MockRuleTest demonstrates the usage of the S3MockRule, which can be configured through a builder.

To use the JUnit4 Rule, use the following Maven artifact in test scope:

<dependency>
 <groupId>com.adobe.testing</groupId>
 <artifactId>s3mock-junit4</artifactId>
 <version>...</version>
 <scope>test</scope>
</dependency>

Start using the JUnit5 Extension

The S3MockExtension can currently be used in two ways:

  1. Declaratively using @ExtendWith(S3MockExtension.class) and by injecting a properly configured instance of AmazonS3 client and/or the started S3MockApplication to the tests. See examples: S3MockExtensionDeclarativeTest (for SDKv1) or S3MockExtensionDeclarativeTest (for SDKv2)

  2. Programmatically using @RegisterExtension and by creating and configuring the S3MockExtension using a builder. See examples: S3MockExtensionProgrammaticTest (for SDKv1) or S3MockExtensionProgrammaticTest (for SDKv2)

To use the JUnit5 Extension, use the following Maven artifact in test scope:

<dependency>
  <groupId>com.adobe.testing</groupId>
  <artifactId>s3mock-junit5</artifactId>
  <version>...</version>
  <scope>test</scope>
</dependency>

Start using the TestNG Listener

The example S3MockListenerXMLConfigurationTest demonstrates the usage of the S3MockListener, which can be configured as shown in testng.xml. The listener bootstraps S3Mock application before TestNG execution starts and shuts down the application just before the execution terminates. Please refer to IExecutionListener

To use the TestNG Listener, use the following Maven artifact in test scope:

<dependency>
 <groupId>com.adobe.testing</groupId>
 <artifactId>s3mock-testng</artifactId>
 <version>...</version>
 <scope>test</scope>
</dependency>

Start programmatically

Include the following dependency and use one of the start methods in com.adobe.testing.s3mock.S3MockApplication:

<dependency>
  <groupId>com.adobe.testing</groupId>
  <artifactId>s3mock</artifactId>
  <version>...</version>
</dependency>

Build & Run

To build this project, you need Docker, JDK 17 or higher, and Maven:

./mvnw clean install

If you want to skip the Docker build, pass the optional parameter "skipDocker":

./mvnw clean install -DskipDocker

You can run the S3Mock from the sources by either of the following methods:

  • Run or Debug the class com.adobe.testing.s3mock.S3MockApplication in the IDE.
  • using Docker:
    • ./mvnw clean package -pl server -am -DskipTests
    • docker run -p 9090:9090 -p 9191:9191 -t adobe/s3mock:latest
  • using the Docker Maven plugin:
    • ./mvnw clean package docker:start -pl server -am -DskipTests -Ddocker.follow -Dit.s3mock.port_http=9090 -Dit.s3mock.port_https=9191 (stop with ctrl-c)

Once the application is started, you can execute the *IT tests from your IDE.

Java

This repo is built with Java 17, output is currently bytecode compatible with Java 17.

Kotlin

The Integration Tests are built in Kotlin.

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

More Repositories

1

brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
JavaScript
33,300
star
2

react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
TypeScript
11,538
star
3

leonardo

Generate colors based on a desired contrast ratio
JavaScript
1,855
star
4

antialiased-cnns

pip install antialiased-cnns to improve stability and accuracy
Python
1,611
star
5

balance-text

A plugin for implementing balancing of wrapping text in a web page
JavaScript
1,362
star
6

adobe.github.com

Adobe central hub for open source
CSS
1,290
star
7

spectrum-web-components

Spectrum Web Components
TypeScript
1,177
star
8

brackets-shell

CEF3-based application shell for Brackets.
Python
1,176
star
9

spectrum-css

The standard CSS implementation of the Spectrum design language.
CSS
1,154
star
10

aem-core-wcm-components

Standardized components to build websites with AEM.
Java
709
star
11

jsonschema2md

Convert Complex JSON Schemas into Markdown Documentation
JavaScript
563
star
12

NLP-Cube

Natural Language Processing Pipeline - Sentence Splitting, Tokenization, Lemmatization, Part-of-speech Tagging and Dependency Parsing
HTML
549
star
13

aem-project-archetype

Maven template to create best-practice websites on AEM.
JavaScript
519
star
14

ferrum

Features from the rust language in javascript: Provides Traits/Type classes & a hashing infrastructure and an advanced library for working with sequences/iterators in js
JavaScript
496
star
15

brackets-app

Deprecated CEF1-based app shell for Brackets. Use https://github.com/adobe/brackets-shell instead.
C++
490
star
16

cryptr

Cryptr: a GUI for Hashicorp's Vault
HTML
487
star
17

cssfilterlab

CSS FilterLab
JavaScript
348
star
18

hyde

A front-end to Jekyll that parses C++ sources to produce and enforce out-of-line documentation
C++
303
star
19

node-smb-server

A 100% JavaScript implementation of the SMB file sharing protocol.
JavaScript
276
star
20

htl-spec

HTML Template Language Specification
275
star
21

aem-guides-wknd

Tutorial Code companion for Getting Started Developing with AEM Sites WKND Tutorial
JavaScript
261
star
22

lit-mobx

Mixin and base class for using mobx with lit-element
TypeScript
260
star
23

xdm

Experience Data Model
JavaScript
235
star
24

lagrange

A Robust Geometry Processing Library
C++
215
star
25

webkit

Experiments and contributions to WebKit. Tracks git://git.webkit.org/WebKit.git
213
star
26

chromium

Experiments and contributions to Chromium project
C++
207
star
27

elixir-styler

An @elixir-lang code-style enforcer that will just FIFY instead of complaining
Elixir
207
star
28

avmplus

Source code for the Actionscript virtual machine
ActionScript
194
star
29

ops-cli

Ops - cli wrapper for Terraform, Ansible, Helmfile and SSH for cloud automation
Python
186
star
30

pdf-embed-api-samples

Samples for Adobe Document Services PDF Embed API
JavaScript
155
star
31

Deep-Audio-Prior

Audio Source Separation Without Any Training Data.
Python
154
star
32

rules_gitops

This repository contains rules for continuous, GitOps driven Kubernetes deployments.
Starlark
151
star
33

aem-htl-repl

Read–Eval–Print Loop environment for HTL.
JavaScript
151
star
34

OSAS

One Stop Anomaly Shop: Anomaly detection using two-phase approach: (a) pre-labeling using statistics, Natural Language Processing and static rules; (b) anomaly scoring using supervised and unsupervised machine learning.
Python
150
star
35

stringlifier

Stringlifier is on Opensource ML Library for detecting random strings in raw text. It can be used in sanitising logs, detecting accidentally exposed credentials and as a pre-processing step in unsupervised ML-based analysis of application text data.
Python
148
star
36

svg-native-viewer

SVG Native viewer is a library that parses and renders SVG Native documents
C++
142
star
37

Spry

Spry is a JavaScript-based framework that enables the rapid development of Ajax-powered web pages.
HTML
140
star
38

XMP-Toolkit-SDK

The XMP Toolkit allows you to integrate XMP functionality into your product or solution
C++
135
star
39

brackets-phonegap

A brackets extension for PhoneGap development.
JavaScript
112
star
40

brackets.io

brackets.io website
HTML
111
star
41

tf-manage

Shell
110
star
42

aem-component-generator

AEM Component Generator is a java project that enables developers to generate the base structure of an AEM component using a JSON configuration file specifying component and dialog properties and other configuration options.
Java
109
star
43

himl

A hierarchical yaml config in Python
Python
107
star
44

adobe-client-data-layer

An event-driven store for all trackable data of your site.
JavaScript
107
star
45

GLS3D

An implementation of OpenGL for Stage3D that can run inside Flash Player 11+
C
105
star
46

coral-spectrum

A JavaScript library of Web Components following Spectrum design patterns.
JavaScript
104
star
47

aem-core-cif-components

A set of configurations and components to get you started with AEM Commerce development
Java
101
star
48

aem-boilerplate

Use this repository template for new AEM projects.
JavaScript
99
star
49

react-webcomponent

This projects automates the wrapping of a React component in a CustomElement.
JavaScript
95
star
50

web-platform

JavaScript
90
star
51

ride

REST API Automation framework for functional, integration, fuzzing, and performance testing
Java
90
star
52

alloy

Alloy is the web SDK for the Adobe Experience Platform.
JavaScript
85
star
53

go-starter

Bootstrap a new project from a template.
Go
83
star
54

asset-share-commons

A modern, open-source asset share reference implementation built on Adobe Experience Manager (AEM)
Java
83
star
55

orc

ORC is a tool for finding violations of C++'s One Definition Rule on the OSX toolchain.
C++
79
star
56

experience-platform-postman-samples

77
star
57

pdfservices-node-sdk-samples

Samples for the Adobe Document Services PDF Tools Node SDK
HTML
77
star
58

sbmc

Sample-based Monte Carlo Denoising using a Kernel-Splatting Network [Siggraph 2019]
Python
76
star
59

git-server

A GitHub Protocol & API emulation
JavaScript
75
star
60

spectrum-tokens

Tokens used by Spectrum, Adobe's design system.
JavaScript
74
star
61

aio-theme

The Adobe I/O theme for building markdown powered sites
JavaScript
70
star
62

aem-sample-we-retail-journal

We.Retail Journal is a sample showcasing SPA Editing capabilities in AEM using React and Angular
CSS
69
star
63

aem-guides-wknd-spa

69
star
64

frontend-regression-validator

Visual regression tool used to compare baseline and updated instances of a website in a deployment pipeline.
Python
67
star
65

blackhole

An HTTP sink (for testing) with optional recording and playback ability
Go
65
star
66

aem-spa-project-archetype

Maven Archetype for creating new AEM SPA projects
CSS
63
star
67

aio-cli

Adobe I/O Extensible CLI
JavaScript
60
star
68

aem-upload

Makes uploading to AEM easier, and can be used as a command line executable or required as a Node.js module.
JavaScript
59
star
69

aem-modernize-tools

A suite of tools to modernize your AEM Sites implementations off legacy features.
Java
58
star
70

dds2atf

Tool for converting DDS files into ATF files suitable for use with the Flash Stage3D API
C++
58
star
71

redux-saga-promise

Create actions that return promises, which are resolved/rejected by a redux saga
JavaScript
58
star
72

aem-react-editable-components

SPA React Editable Components for Adobe Experience Manager
TypeScript
55
star
73

xmp-docs

XMP documentation
52
star
74

adobe-photoshop-api-sdk

Adobe Photoshop API SDK
JavaScript
50
star
75

aem-enablement

Content required for AEM Enablement
Java
50
star
76

brackets-edge-web-fonts

Edge Web Fonts extension for Brackets. Simply unzip and drop into your Brackets extension folder to browse and include Edge Web Fonts.
JavaScript
50
star
77

aem-brackets-extension

Brackets extension for Adobe Experience Manager (AEM) front-end developers with auto-sync and HTL support.
JavaScript
50
star
78

helix-home

The home of Project Helix
HTML
49
star
79

aem-testing-clients

Testing tools for Adobe Experience Manager
Java
49
star
80

aem-guides-wknd-graphql

JavaScript
47
star
81

brackets-registry

A registry system for hosting Brackets extensions powered by node.js
JavaScript
46
star
82

helix-cli

Command-line tools for developing with AEM
JavaScript
46
star
83

htlengine

An HTL (Sightly) Interpreter/Compiler for Node.js
HTML
45
star
84

aem-dispatcher-experiments

Experiments to demonstrate the impact of the Dispatcher and it's configuration parameters.
HTML
44
star
85

pdfservices-python-sdk-samples

Adobe PDFServices python SDK Samples
Python
44
star
86

node-fetch-retry

Node Module for performing retries using node-fetch
JavaScript
42
star
87

commerce-cif-connector

AEM Commerce connector for Magento and GraphQL
Java
42
star
88

aem-react-core-wcm-components

41
star
89

behavior_tree_editor

A visual editor for building behavior trees for the bots
JavaScript
41
star
90

libLOL

Python
40
star
91

starter-repo

Documentation templates for use in open source and open development projects
40
star
92

commerce-cif-magento

Adobe Commerce Integration Framework (CIF) Magento Integration
JavaScript
40
star
93

bin2c

Convert to/Embed binary files in C source files, quickly and efficiently.
C
38
star
94

graphicalweb-keynote

Keynote for Graphical Web Conference
JavaScript
37
star
95

aem-site-template-standard

Basic site template for AEM that allows non-Java experts to create new sites by customizing CSS and JS only.
SCSS
37
star
96

aio-cli-plugin-cloudmanager

Cloud Manager plugin for the Adobe I/O CLI
JavaScript
37
star
97

oss-contributors

How do tech companies rank amongst themselves when it comes to github.com activity?
JavaScript
35
star
98

aem-eclipse-developer-tools

The Eclipse plugin that brings you the full connection to the Adobe Experience Manager, with auto-sync and project creation wizard.
Java
35
star
99

fetch

Simplified HTTP/1(.1) and HTTP/2 requests with Server Push Support
JavaScript
34
star
100

PDFServices.NET.SDK.Samples

This .NET sample solution helps you get started with the Adobe PDF Services SDK.
HTML
33
star