This project impements an verifyPolicyJSON method that:
- takes in a single argument - an AWS IAM Policy string as []bytes
- verifies whether the []bytes string is a valid AWS::IAM::Role Policy
- returns a bool value: true if the Resource policy field contains exactly one asterisk character, otherwise it returns false (inluding when the policy is invalid)
The method can be executed by running main.go - it reads JSON from data.json (which should be located in the root working directory), passes it to verifyPolicyJSON and prints out the function's result.
I've tested the project on go1.22.2, I cannot guarantee it will work on older versions.
Link to download Golang version 1.22.2: https://go.dev/dl/
- Clone the project
$ git clone https://github.com/Matb85/remitly-home-assignment.git
$ cd ./remitly-home-assignment
- Install dependencies
$ go get ./...
# or
$ go mod download
- Prepare data and insert it to the data.json file
$ echo YOURDATA >> data.json
- Run the project
$ go run ./main.go
- Alternatively, build & run the project
$ go build ./main.go
$ ./main
I have written several unit tests for verifyPolicyJSON and UnmarshalJSON methods in order to ensure that everything works as expected.
To run the test suite, execute the following command:
$ go test ./...