-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ConfigImpl.prioritizeSshRsaKeyAlgorithm to deal with broken…
… backward compatibility
- Loading branch information
1 parent
7d01e7e
commit 13b4044
Showing
3 changed files
with
96 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package net.schmizz.sshj | ||
|
||
import com.hierynomus.sshj.key.KeyAlgorithms | ||
import spock.lang.Specification | ||
|
||
class ConfigImplSpec extends Specification { | ||
static def ECDSA = KeyAlgorithms.ECDSASHANistp521() | ||
static def ED25519 = KeyAlgorithms.EdDSA25519() | ||
static def RSA_SHA_256 = KeyAlgorithms.RSASHA256() | ||
static def RSA_SHA_512 = KeyAlgorithms.RSASHA512() | ||
static def SSH_RSA = KeyAlgorithms.SSHRSA() | ||
|
||
def "prioritizeSshRsaKeyAlgorithm does nothing if there is no ssh-rsa"() { | ||
given: | ||
def config = new DefaultConfig() | ||
config.keyAlgorithms = [RSA_SHA_512, ED25519] | ||
|
||
when: | ||
config.prioritizeSshRsaKeyAlgorithm() | ||
|
||
then: | ||
config.keyAlgorithms == [RSA_SHA_512, ED25519] | ||
} | ||
|
||
def "prioritizeSshRsaKeyAlgorithm does nothing if there is no rsa-sha2-any"() { | ||
given: | ||
def config = new DefaultConfig() | ||
config.keyAlgorithms = [ED25519, SSH_RSA, ECDSA] | ||
|
||
when: | ||
config.prioritizeSshRsaKeyAlgorithm() | ||
|
||
then: | ||
config.keyAlgorithms == [ED25519, SSH_RSA, ECDSA] | ||
} | ||
|
||
def "prioritizeSshRsaKeyAlgorithm does nothing if ssh-rsa already has higher priority"() { | ||
given: | ||
def config = new DefaultConfig() | ||
config.keyAlgorithms = [ED25519, SSH_RSA, RSA_SHA_512, ECDSA] | ||
|
||
when: | ||
config.prioritizeSshRsaKeyAlgorithm() | ||
|
||
then: | ||
config.keyAlgorithms == [ED25519, SSH_RSA, RSA_SHA_512, ECDSA] | ||
} | ||
|
||
def "prioritizeSshRsaKeyAlgorithm prioritizes ssh-rsa if there is one rsa-sha2-any is prioritized"() { | ||
given: | ||
def config = new DefaultConfig() | ||
config.keyAlgorithms = [ED25519, RSA_SHA_512, ECDSA, SSH_RSA] | ||
|
||
when: | ||
config.prioritizeSshRsaKeyAlgorithm() | ||
|
||
then: | ||
config.keyAlgorithms == [ED25519, SSH_RSA, RSA_SHA_512, ECDSA] | ||
} | ||
|
||
def "prioritizeSshRsaKeyAlgorithm prioritizes ssh-rsa if there are two rsa-sha2-any is prioritized"() { | ||
given: | ||
def config = new DefaultConfig() | ||
config.keyAlgorithms = [ED25519, RSA_SHA_512, ECDSA, RSA_SHA_256, SSH_RSA] | ||
|
||
when: | ||
config.prioritizeSshRsaKeyAlgorithm() | ||
|
||
then: | ||
config.keyAlgorithms == [ED25519, SSH_RSA, RSA_SHA_512, ECDSA, RSA_SHA_256] | ||
} | ||
} |