// Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java
// public class FilteredCommand {
// 	
// 	private String command;
// 	private String argument;
// 
// 	public FilteredCommand() {
// 	}
// 	
// 	public FilteredCommand(String command, String argument) {
// 		this.command = command;
// 		this.argument = argument;
// 	}
// 
// 	public void setArgument(String argument) {
// 		this.argument = argument;
// 	}
// 	
// 	public void setCommand(String command) {
// 		this.command = command;
// 	}
// 
// 	public String getCommand() {
// 		return this.command;
// 	}
// 
// 	public String getArgument() {
// 		return this.argument;
// 	}
// 	
// 	@Override
// 	public String toString()
// 	{
// 		return "Filtered Command: " + getCommand() + ", " + getArgument();
// 	}
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java
// public class BadCommandException extends Exception {
// 
// 	private static final long serialVersionUID = 4904880805323643780L;
// 
// 	public BadCommandException(String reason) {
// 		super(reason);
// 	}
// 
// 	public BadCommandException() {
// 	}
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java
// public class GitBadCommandFilter implements IBadCommandFilter {
// 	
// //	private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$");
// 	private static final String commandFilter = "^'.+'$";
// 	private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"};
// 	private String[] parts;
// 
// 	public GitBadCommandFilter() {
// 	}
// 	
// 	public FilteredCommand filterOrThrow(String command) throws BadCommandException {
// 		command = new GitCommandSeamer(command).toString();
// 		checkForNewlines(command);
// 		parts = checkForOneArgument(command);
// 		throwIfContains(parts[1], "..");
// 		throwIfContains(parts[1], "!");
// 		checkAgainstPattern(parts[1]);
// 		checkValidCommands(parts[0]);
// 		parts[1] = parts[1].replaceAll("^'", "");
// 		parts[1] = parts[1].replaceAll("'$", "");
// 		return new FilteredCommand(parts[0], parts[1]);
// 	}
// 
// 	private void checkValidCommands(String commandToCheck) throws BadCommandException {
// 		for (String validCommand : validCommands) {
// 			if (validCommand.equals(commandToCheck)){
// 				return;
// 			}
// 		}
// 		throw new BadCommandException("Unknown Command: " + commandToCheck);
// 	}
// 
// 	private void checkAgainstPattern(String command) throws BadCommandException {
// 		if (!Pattern.matches(commandFilter, command))
// 		{
// 			throw new BadCommandException();
// 		}
// 	}
// 
// 	private String[] checkForOneArgument(String command) throws BadCommandException {
// 		String[] parts = command.split(" ");
// 		int count = parts.length;
// 		if (count == 1 || count > 2)
// 		{
// 			throw new BadCommandException("Invalid Number Of Arguments (must be 1): " + count);
// 		}
// 		return parts;
// 	}
// 
// 	private void checkForNewlines(String command) throws BadCommandException {
// 		throwIfContains(command, "\n");
// 		throwIfContains(command, "\r");
// 	}
// 
// 	private void throwIfContains(String command, String toCheckFor) throws BadCommandException {
// 		if (command.contains(toCheckFor)){
// 			throw new BadCommandException("Cant Contain: " + toCheckFor);
// 		}
// 	}
// 	
// 	public String getCommand()
// 	{
// 		return parts[0];
// 	}
// 	
// 	public String getArgument()
// 	{
// 		return parts[1];
// 	}
// 
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Test;
import com.asolutions.scmsshd.commands.FilteredCommand;
import com.asolutions.scmsshd.commands.filters.BadCommandException;
import com.asolutions.scmsshd.commands.filters.git.GitBadCommandFilter;
		assertThrows("ev\ril");
	}
	
	@Test
	public void testNoArgs() throws Exception {
		assertThrows("git-upload-pack");
	}
	
	@Test
	public void test2Args() throws Exception {
		assertThrows("git-upload-pack bob tom");
	}
	
	@Test
	public void testUnquoted() throws Exception {
		assertThrows("git-upload-pack bob");
	}
	
	@Test
	public void testWithUnsafeBang() throws Exception {
		assertThrows("git-upload-pack 'ev!l'");
	}
	
	@Test
	public void testWithUnsafeDotDot() throws Exception {
		assertThrows("git-upload-pack 'something/../evil'");
	}
	
	private void assertThrows(String toCheck) {
		try{
// Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java
// public class FilteredCommand {
// 	
// 	private String command;
// 	private String argument;
// 
// 	public FilteredCommand() {
// 	}
// 	
// 	public FilteredCommand(String command, String argument) {
// 		this.command = command;
// 		this.argument = argument;
// 	}
// 
// 	public void setArgument(String argument) {
// 		this.argument = argument;
// 	}
// 	
// 	public void setCommand(String command) {
// 		this.command = command;
// 	}
// 
// 	public String getCommand() {
// 		return this.command;
// 	}
// 
// 	public String getArgument() {
// 		return this.argument;
// 	}
// 	
// 	@Override
// 	public String toString()
// 	{
// 		return "Filtered Command: " + getCommand() + ", " + getArgument();
// 	}
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java
// public class BadCommandException extends Exception {
// 
// 	private static final long serialVersionUID = 4904880805323643780L;
// 
// 	public BadCommandException(String reason) {
// 		super(reason);
// 	}
// 
// 	public BadCommandException() {
// 	}
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java
// public class GitBadCommandFilter implements IBadCommandFilter {
// 	
// //	private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$");
// 	private static final String commandFilter = "^'.+'$";
// 	private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"};
// 	private String[] parts;
// 
// 	public GitBadCommandFilter() {
// 	}
// 	
// 	public FilteredCommand filterOrThrow(String command) throws BadCommandException {
// 		command = new GitCommandSeamer(command).toString();
// 		checkForNewlines(command);
// 		parts = checkForOneArgument(command);
// 		throwIfContains(parts[1], "..");
// 		throwIfContains(parts[1], "!");
// 		checkAgainstPattern(parts[1]);
// 		checkValidCommands(parts[0]);
// 		parts[1] = parts[1].replaceAll("^'", "");
// 		parts[1] = parts[1].replaceAll("'$", "");
// 		return new FilteredCommand(parts[0], parts[1]);
// 	}
// 
// 	private void checkValidCommands(String commandToCheck) throws BadCommandException {
// 		for (String validCommand : validCommands) {
// 			if (validCommand.equals(commandToCheck)){
// 				return;
// 			}
// 		}
// 		throw new BadCommandException("Unknown Command: " + commandToCheck);
// 	}
// 
// 	private void checkAgainstPattern(String command) throws BadCommandException {
// 		if (!Pattern.matches(commandFilter, command))
// 		{
// 			throw new BadCommandException();
// 		}
// 	}
// 
// 	private String[] checkForOneArgument(String command) throws BadCommandException {
// 		String[] parts = command.split(" ");
// 		int count = parts.length;
// 		if (count == 1 || count > 2)
// 		{
// 			throw new BadCommandException("Invalid Number Of Arguments (must be 1): " + count);
// 		}
// 		return parts;
// 	}
// 
// 	private void checkForNewlines(String command) throws BadCommandException {
// 		throwIfContains(command, "\n");
// 		throwIfContains(command, "\r");
// 	}
// 
// 	private void throwIfContains(String command, String toCheckFor) throws BadCommandException {
// 		if (command.contains(toCheckFor)){
// 			throw new BadCommandException("Cant Contain: " + toCheckFor);
// 		}
// 	}
// 	
// 	public String getCommand()
// 	{
// 		return parts[0];
// 	}
// 	
// 	public String getArgument()
// 	{
// 		return parts[1];
// 	}
// 
// }


// Path: src/test/java/com/asolutions/scmsshd/commands/git/GitBadCommandFilterTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Test;
import com.asolutions.scmsshd.commands.FilteredCommand;
import com.asolutions.scmsshd.commands.filters.BadCommandException;
import com.asolutions.scmsshd.commands.filters.git.GitBadCommandFilter;

		assertThrows("ev\ril");
	}
	
	@Test
	public void testNoArgs() throws Exception {
		assertThrows("git-upload-pack");
	}
	
	@Test
	public void test2Args() throws Exception {
		assertThrows("git-upload-pack bob tom");
	}
	
	@Test
	public void testUnquoted() throws Exception {
		assertThrows("git-upload-pack bob");
	}
	
	@Test
	public void testWithUnsafeBang() throws Exception {
		assertThrows("git-upload-pack 'ev!l'");
	}
	
	@Test
	public void testWithUnsafeDotDot() throws Exception {
		assertThrows("git-upload-pack 'something/../evil'");
	}
	
	private void assertThrows(String toCheck) {
		try{
			GitBadCommandFilter filter = new GitBadCommandFilter();