# Tests

Some tests with serverspec framework to verify Qualys, Splunk, and Trend Micro Deep Security agents installation.

## Pre-requires

Create `~/.ssh/config` with the following content:

```shell script
Host dev-infra-sma-api-cache-warmup-01 10.50.13.133
  User ubuntu
  HostName 10.50.13.133
  IdentityFile ~/.ssh/dev-infra-default.pem

Host dev-infra-manual-testing-01 10.50.13.76
  User ubuntu
  HostName 10.50.13.76
  IdentityFile ~/.ssh/dev-infra-default.pem

Host dev-infra-openvpn1 3.209.52.125
  User openvpnas
  HostName 3.209.52.125
  IdentityFile ~/.ssh/dev-infra-default.pem

Host dev-infra-sentry-01 54.226.112.32
  User ec2-user
  HostName 54.226.112.32
  IdentityFile ~/.ssh/dev-infra-default.pem

Host dev-infra-jenkins-master-01 54.157.151.112
  User ec2-user
  HostName 54.157.151.112
  IdentityFile ~/.ssh/dev-infra-jenkins-default.pem

Host dev-infra-nexus-01 54.90.252.206
  User ec2-user
  HostName 54.90.252.206
  IdentityFile ~/.ssh/dev-infra-default.pem

Host dev-infra-squid-01 10.50.14.130
  User ec2-user
  HostName 10.50.14.130
  IdentityFile ~/.ssh/dev-infra-default.pem

Host dev-infra-dapc43-01 10.50.13.217
  User ubuntu
  HostName 10.50.13.217
  IdentityFile ~/.ssh/dev-infra-default.pem
```

By default, serverspec will be checking on how to connect to the host in `~/.ssh/config`. If there is no information about host in `~/.ssh/config` default behavior will be used e.g. your username and default ssh key.

Make sure you've all the following private keys in your `~/.ssh` folder:

* dev-infra-default.pem
* dev-infra-jenkins-default.pem

If not, you can download them from Secrets Manager. 

## Run tests

### Docker

First of all you'll need to build a docker image locally, you can do it using the following command:

```
docker build -t serverspec .
```

After that you can run tests using the following command:

```
docker run \
    -ti \
    --rm \
    -v "${HOME}/.ssh":/root/.ssh \
    -v "$(pwd)":/workspace \
    serverspec
```

### Locally 

Install serverspec locally 

```
gem install serverspec
``` 

Run tests

```
rake spec
```
