public async void OverwriteHostedFile() { await TestClient.ClientLogin(TeamServer.Helpers.GeneratePseudoRandomString(6), "a"); var listener = await StartHttpListener(); var content = "this is a test"; var hostedFile = new NewHostedFileRequest { Uri = "/a", EncodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes(content)), MimeType = MimeType.Text_Plain }; await TestClient.HttpClient.PostAsync($"api/Listeners/{listener.ListenerId}/hostfile", Helpers.Serialise(hostedFile)); var newContent = "this is a another test"; var newHostedFile = new NewHostedFileRequest { Uri = "/a", EncodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes(newContent)), MimeType = MimeType.Text_Plain }; await TestClient.HttpClient.PostAsync($"api/Listeners/{listener.ListenerId}/hostfile", Helpers.Serialise(newHostedFile)); var apiReq = await TestClient.HttpClient.GetAsync("api/Listeners/hostedfiles"); var result = Helpers.Deserialise <List <HostedFileResponse> >(apiReq.Content.ReadAsStringAsync()); Assert.Equal(newHostedFile.Uri, result[0].Uri); Assert.Equal(newContent.Length, result[0].DataLength); Assert.Equal(newHostedFile.MimeType, result[0].MimeType); }
public async void InvalidRequest(string nick, string pass) { var result = await TestClient.ClientLogin(nick, pass); Assert.Equal(ClientAuthenticationResult.AuthResult.InvalidRequest, result.Result); Assert.Null(result.Token); }
public async void BadPassword() { var result = await TestClient.ClientLogin(TeamServer.Helpers.GeneratePseudoRandomString(6), "b"); Assert.Equal(ClientAuthenticationResult.AuthResult.BadPassword, result.Result); Assert.Null(result.Token); }
public async void LoginSuccess() { var result = await TestClient.ClientLogin(TeamServer.Helpers.GeneratePseudoRandomString(6), "a"); Assert.Equal(ClientAuthenticationResult.AuthResult.LoginSuccess, result.Result); Assert.NotNull(result.Token); }
public async void NickInUse() { var user = TeamServer.Helpers.GeneratePseudoRandomString(6); await TestClient.ClientLogin(user, "a"); var result = await TestClient.ClientLogin(user, "a"); Assert.Equal(ClientAuthenticationResult.AuthResult.NickInUse, result.Result); Assert.Null(result.Token); }
internal async Task <ListenerTcp> StartTcpListener() { await TestClient.ClientLogin(TeamServer.Helpers.GeneratePseudoRandomString(6), "a"); var listenerRequest = new NewTcpListenerRequest { BindAddress = "0.0.0.0", BindPort = 8080, }; var apiReq = await TestClient.HttpClient.PostAsync("api/Listeners/tcp", Helpers.Serialise(listenerRequest)); return(Helpers.Deserialise <ListenerTcp>(apiReq.Content.ReadAsStringAsync())); }
public async void StartTcpListener() { await TestClient.ClientLogin(TeamServer.Helpers.GeneratePseudoRandomString(6), "a"); var listenerRequest = new NewTcpListenerRequest { BindAddress = "0.0.0.0", BindPort = 8080, }; var apiReq = await TestClient.HttpClient.PostAsync("api/Listeners/tcp", Helpers.Serialise(listenerRequest)); var result = Helpers.Deserialise <ListenerTcp>(apiReq.Content.ReadAsStringAsync()); Assert.Equal(ListenerType.TCP, result.Type); Assert.Equal("0.0.0.0", result.BindAddress); Assert.Equal(8080, result.BindPort); }
public async void GenerateHttpAgentPayloadFail() { await TestClient.ClientLogin(TeamServer.Helpers.GeneratePseudoRandomString(6), "a"); var payloadRequest = new PayloadRequest { ListenerId = "blah", OutputType = OutputType.Exe, TargetFramework = TargetFramework.Net40 }; var apiReq = await TestClient.HttpClient.PostAsync("api/Payload", Helpers.Serialise(payloadRequest)); var result = Helpers.Deserialise <PayloadResponse>(apiReq.Content.ReadAsStringAsync()); Assert.Equal(CompilerStatus.Fail, result.CompilerStatus); Assert.Null(result.EncodedAssembly); Assert.NotNull(result.ErrorMessage); }