Skip to content

This CLI application authorizes a transaction according predefined rules

License

Notifications You must be signed in to change notification settings

r1cm3d/authorizer

Repository files navigation

authorizer

This CLI application authorizes a transaction according predefined rules

Table of Contents

TLDR

./configure

Configure will check if all prerequisites are installed. It uses command application. See: Important Disclaimer at the top of the configure file for troubleshooting.

make && make install

To assemble Docker container and create executable file (just an alias for docker run command).

./authorizer < data/operations

The output should be:

{"Account":{"active-card":true,"available-limit":100},"violations":[]}
{"Account":{"active-card":true,"available-limit":80},"violations":[]}
{"Account":{"active-card":true,"available-limit":80},"violations":["insufficient-limit"]}
{"Account":{"active-card":true,"available-limit":50},"violations":[]}

Running on Bash

Running on On My Zsh

Prerequisites

Diff 3.7 Make 4.2.1 Go 1.16 Docker 20.10.2

To run in Docker container

You only need Make (tested with GNU Make 4.2.1, but it should work on others) and Docker (tested with Docker version 20.10.2, build 2291f61) installed. It is important to give execution permission for scripts/:

chmod +x scripts/

They are safe, but you could check it out if you don't believe me. 😄

To run locally

Go 1.16 ecosystem installed. I'm pretty sure it might work in the recent old versions 1.1[0-6], but I actually did not test.

About

Authorizer is a tiny CLI application that receives a series of events through standard input, process them and returns the results in standard output. For a matter of simplicity, this application cannot run in concurrent environments, there is neither synchronization nor lock strategy to read or write into timeline data structure.

Test

Unit test

make unit-test

The you only need Go 1.16 ecosystem to run it. Easy peasy.

Integration test

make integration-test

Integration tests calls make install target to create authorizer executable and call it through integration test. This test just guarantees that main function is calling internal services properly. It needs Make to run it.

Both of them

make test

Acceptance test

make install && ./acceptance_tests

Acceptance tests emulates the real execution of the application. It uses all input data files stored into data directory and compares the result with each respective expected output file. It was tested on Bash and On My Zsh. I did not test it on others unpopular shells as csh, sh or pwsh.