-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hugefiver <[email protected]>
- Loading branch information
Showing
19 changed files
with
618 additions
and
86 deletions.
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
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
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 |
---|---|---|
|
@@ -254,3 +254,93 @@ func TestNewClientConn(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestUnsupportedAlgorithm(t *testing.T) { | ||
for _, tt := range []struct { | ||
name string | ||
config Config | ||
wantError string | ||
}{ | ||
{ | ||
"unsupported KEX", | ||
Config{ | ||
KeyExchanges: []string{"unsupported"}, | ||
}, | ||
"no common algorithm", | ||
}, | ||
{ | ||
"unsupported and supported KEXs", | ||
Config{ | ||
KeyExchanges: []string{"unsupported", kexAlgoCurve25519SHA256}, | ||
}, | ||
"", | ||
}, | ||
{ | ||
"unsupported cipher", | ||
Config{ | ||
Ciphers: []string{"unsupported"}, | ||
}, | ||
"no common algorithm", | ||
}, | ||
{ | ||
"unsupported and supported ciphers", | ||
Config{ | ||
Ciphers: []string{"unsupported", chacha20Poly1305ID}, | ||
}, | ||
"", | ||
}, | ||
{ | ||
"unsupported MAC", | ||
Config{ | ||
MACs: []string{"unsupported"}, | ||
// MAC is used for non AAED ciphers. | ||
Ciphers: []string{"aes256-ctr"}, | ||
}, | ||
"no common algorithm", | ||
}, | ||
{ | ||
"unsupported and supported MACs", | ||
Config{ | ||
MACs: []string{"unsupported", "[email protected]"}, | ||
// MAC is used for non AAED ciphers. | ||
Ciphers: []string{"aes256-ctr"}, | ||
}, | ||
"", | ||
}, | ||
} { | ||
t.Run(tt.name, func(t *testing.T) { | ||
c1, c2, err := netPipe() | ||
if err != nil { | ||
t.Fatalf("netPipe: %v", err) | ||
} | ||
defer c1.Close() | ||
defer c2.Close() | ||
|
||
serverConf := &ServerConfig{ | ||
Config: tt.config, | ||
PasswordCallback: func(conn ConnMetadata, password []byte) (*Permissions, error) { | ||
return &Permissions{}, nil | ||
}, | ||
} | ||
serverConf.AddHostKey(testSigners["rsa"]) | ||
go NewServerConn(c1, serverConf) | ||
|
||
clientConf := &ClientConfig{ | ||
User: "testuser", | ||
Config: tt.config, | ||
Auth: []AuthMethod{ | ||
Password("testpw"), | ||
}, | ||
HostKeyCallback: InsecureIgnoreHostKey(), | ||
} | ||
_, _, _, err = NewClientConn(c2, "", clientConf) | ||
if err != nil { | ||
if tt.wantError == "" || !strings.Contains(err.Error(), tt.wantError) { | ||
t.Errorf("%s: got error %q, missing %q", tt.name, err.Error(), tt.wantError) | ||
} | ||
} else if tt.wantError != "" { | ||
t.Errorf("%s: succeeded, but want error string %q", tt.name, tt.wantError) | ||
} | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
64c3993f5c824fe7febbf8561179da523a4e98ea | ||
Wed Jun 7 05:24:56 2023 +0000 | ||
b4ddeeda5bc71549846db71ba23e83ecb26f36ed | ||
Fri Aug 4 16:27:49 2023 +0000 |
Oops, something went wrong.