Skip to content

Commit

Permalink
test for socks 5 auth tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
mllken committed Oct 29, 2022
1 parent 2a24809 commit 4404b8d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions socks.zig
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,8 @@ test "mock SOCKS 5 server" {
const expected = [_]u8{
// 1st packet: method none auth
Socksv5.VERSION, 0x01, 0,
// 2nd packet
Socksv5.VERSION,
@enumToInt(Socksv5.Cmd.Connect),
0x00, 0x01, 127, 0, 0, 1, 0x20, 0xfb // rsrv, atyp, IPv4, port
// 2nd packet - vers, method, rsrv, atyp, IPv4, port
Socksv5.VERSION, @enumToInt(Socksv5.Cmd.Connect), 0x00, 0x01, 127, 0, 0, 1, 0x20, 0xfb
};
try std.testing.expectEqualStrings(client_stream.getWritten(), &expected);

Expand All @@ -383,19 +381,18 @@ test "mock SOCKS 5 server" {

const ai = Socksv5.AuthInfo{
.user = "a",
.password = "xxx",
.password = "xyz",
};
try Socksv5.clientAddress(server_stream2.reader(), client_stream.writer(), ai, dst);

const expected2 = [_]u8{
// 1st packet: method userpassword auth
Socksv5.VERSION, 0x02, @enumToInt(Socksv5.Auth.MethodNone), @enumToInt(Socksv5.Auth.MethodUserPassword),
// 2nd packet: auth info
Socksv5.Auth.VERSION, 0x01, 'a', 0x03, 'x', 'x', 'x',
// 3rd packet - rsrv, atyp, IPv4, port
Socksv5.Auth.VERSION, 0x01, 'a', 0x03, 'x', 'y', 'z',
// 3rd packet - vers, method, rsrv, atyp, IPv4, port
Socksv5.VERSION, @enumToInt(Socksv5.Cmd.Connect), 0x00, 0x01, 127, 0, 0, 1, 0x20, 0xfb
};

try std.testing.expectEqualStrings(client_stream.getWritten(), &expected2);
}

Expand Down

0 comments on commit 4404b8d

Please sign in to comment.