package de.widdix.awsec2ssh;

import com.amazonaws.services.cloudformation.model.Parameter;
import org.junit.Test;

public class TestShowcase extends ACloudFormationTest {

    @Test
    public void testCentOS() throws Exception {
        final String stackName = "showcase-rpm-" + this.random8String();
        final String userName = "user-" + this.random8String();
        try {
            final User user = this.createUser(userName);
            try {
                this.createStack(stackName,
                        "showcase-rpm.yaml",
                        new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()),
                        new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()),
                        new Parameter().withParameterKey("OS").withParameterValue("CentOS")
                );
                final String host = this.getStackOutputValue(stackName, "PublicName");
                this.probeSSH(host, user);
            } finally {
                this.deleteStack(stackName);
            }
        } finally {
            this.deleteUser(userName);
        }
    }

    @Test
    public void testRHEL() throws Exception {
        final String stackName = "showcase-rpm-" + this.random8String();
        final String userName = "user-" + this.random8String();
        try {
            final User user = this.createUser(userName);
            try {
                this.createStack(stackName,
                        "showcase-rpm.yaml",
                        new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()),
                        new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()),
                        new Parameter().withParameterKey("OS").withParameterValue("RHEL")
                );
                final String host = this.getStackOutputValue(stackName, "PublicName");
                this.probeSSH(host, user);
            } finally {
                this.deleteStack(stackName);
            }
        } finally {
            this.deleteUser(userName);
        }
    }

    @Test
    public void testSUSELinuxEnterpriseServer() throws Exception {
        final String stackName = "showcase-rpm-" + this.random8String();
        final String userName = "user-" + this.random8String();
        try {
            final User user = this.createUser(userName);
            try {
                this.createStack(stackName,
                        "showcase-rpm.yaml",
                        new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()),
                        new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()),
                        new Parameter().withParameterKey("OS").withParameterValue("SUSELinuxEnterpriseServer")
                );
                final String host = this.getStackOutputValue(stackName, "PublicName");
                this.probeSSH(host, user);
            } finally {
                this.deleteStack(stackName);
            }
        } finally {
            this.deleteUser(userName);
        }
    }

    @Test
    public void testUbuntu() throws Exception {
        final String stackName = "showcase-rpm-" + this.random8String();
        final String userName = "user-" + this.random8String();
        try {
            final User user = this.createUser(userName);
            try {
                this.createStack(stackName,
                        "showcase-rpm.yaml",
                        new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()),
                        new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()),
                        new Parameter().withParameterKey("OS").withParameterValue("Ubuntu")
                );
                final String host = this.getStackOutputValue(stackName, "PublicName");
                this.probeSSH(host, user);
            } finally {
                this.deleteStack(stackName);
            }
        } finally {
            this.deleteUser(userName);
        }
    }

    @Test
    public void testAmazonLinux2() throws Exception {
        final String stackName = "showcase-rpm-" + this.random8String();
        final String userName = "user-" + this.random8String();
        try {
            final User user = this.createUser(userName);
            try {
                this.createStack(stackName,
                        "showcase-rpm.yaml",
                        new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()),
                        new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()),
                        new Parameter().withParameterKey("OS").withParameterValue("AmazonLinux2")
                );
                final String host = this.getStackOutputValue(stackName, "PublicName");
                this.probeSSH(host, user);
            } finally {
                this.deleteStack(stackName);
            }
        } finally {
            this.deleteUser(userName);
        }
    }

    @Test
    public void testDefaultAmazonLinux() throws Exception {
        final String stackName = "showcase-rpm-" + this.random8String();
        final String userName = "user-" + this.random8String();
        try {
            final User user = this.createUser(userName);
            try {
                this.createStack(stackName,
                        "showcase-rpm.yaml",
                        new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()),
                        new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId())
                );
                final String host = this.getStackOutputValue(stackName, "PublicName");
                this.probeSSH(host, user);
            } finally {
                this.deleteStack(stackName);
            }
        } finally {
            this.deleteUser(userName);
        }
    }

}

@@ -134,16 +134,19 @@
 Showcase
+RPM
  extends
@@ -169,16 +169,82 @@
 Test %7B%0A%0A
+    // TODO make Version parameter configurable via ENV variable%0A%0A
     @Tes

fix class name