-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Honeytrap | ||
* Copyright (C) 2016-2017 DutchSec (https://dutchsec.com/) | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Affero General Public License version 3 as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* version 3 along with this program in the file "LICENSE". If not, see | ||
* <http://www.gnu.org/licenses/agpl-3.0.txt>. | ||
* | ||
* See https://honeytrap.io/ for more details. All requests should be sent to | ||
* licensing@honeytrap.io | ||
* | ||
* The interactive user interfaces in modified source and object code versions | ||
* of this program must display Appropriate Legal Notices, as required under | ||
* Section 5 of the GNU Affero General Public License version 3. | ||
* | ||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, | ||
* these Appropriate Legal Notices must retain the display of the "Powered by | ||
* Honeytrap" logo and retain the original copyright notice. If the display of the | ||
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | ||
* must display the words "Powered by Honeytrap" and retain the original copyright notice. | ||
*/ | ||
package rdp | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"net" | ||
"testing" | ||
) | ||
|
||
func TestRDP_Connect(t *testing.T) { | ||
server, client := net.Pipe() | ||
defer server.Close() | ||
defer client.Close() | ||
|
||
c := RDP() | ||
|
||
go c.Handle(context.TODO(), server) | ||
|
||
test := []byte("test") | ||
if _, err := client.Write(test); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
buffer := make([]byte, 255) | ||
if n, err := client.Read(buffer[:]); err != nil { | ||
t.Error(err) | ||
} else { | ||
buffer = buffer[:n] | ||
} | ||
|
||
if !bytes.Equal(test, buffer) { | ||
t.Errorf("Test failed: got %+#v, expected %+#v", buffer, test) | ||
return | ||
} | ||
} |