-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Techdebt: Remove ECDSA dependency (#7356)
- Loading branch information
Showing
6 changed files
with
145 additions
and
53 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
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 |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
qusUO07jKuSxzPumXBeU+JEtx0J1tqZwJlpGt2R+0qN7nKnPl2+hx \ | ||
[email protected]""" | ||
|
||
RSA_PUBLIC_KEY_RFC4716 = b"""\ | ||
RSA_PUBLIC_KEY_RFC4716_1 = b"""\ | ||
---- BEGIN SSH2 PUBLIC KEY ---- | ||
AAAAB3NzaC1yc2EAAAADAQABAAABAQDusXfgTE4eBP50NglSzCSEGnIL6+cr6m3H6cZANO | ||
Q+P1o/W4BdtcAL3sor4iGi7SOeJgo8kweyMQrhrt6HaKGgromRiz37LQx4YIAcBi4Zd023 | ||
|
@@ -38,6 +38,44 @@ | |
---- END SSH2 PUBLIC KEY ---- | ||
""" | ||
|
||
RSA_PUBLIC_KEY_RFC4716_2 = b"""\ | ||
---- BEGIN SSH2 PUBLIC KEY ---- | ||
cOmmENt: [email protected] | ||
AAAAB3NzaC1yc2EAAAADAQABAAABAQDusXfgTE4eBP50NglSzCSEGnIL6+cr6m3H6cZANO | ||
Q+P1o/W4BdtcAL3sor4iGi7SOeJgo8kweyMQrhrt6HaKGgromRiz37LQx4YIAcBi4Zd023 | ||
mO/V7Rc2Chh18mWgLSmA6ng+j37ip6452zxtv0jHAz9pJolbKBpJzbZlPN45ZCTk9ck0fS | ||
VHRl6VRSSPQcpqi65XpRf+35zNOCGCc1mAOOTmw59Q2a6A3t8mL7r91aM5q6QOQm219lct | ||
FM8O7HRJnDgmhGpnjRwE1LyKktWTbgFZ4SNWU2XqusUO07jKuSxzPumXBeU+JEtx0J1tqZ | ||
wJlpGt2R+0qN7nKnPl2+hx | ||
---- END SSH2 PUBLIC KEY ---- | ||
""" | ||
|
||
RSA_PUBLIC_KEY_RFC4716_3 = b"""\ | ||
---- BEGIN SSH2 PUBLIC KEY ---- | ||
Comment: "1024-bit RSA, converted from OpenSSH by [email protected]" | ||
x-command: /home/me/bin/lock-in-guest.sh | ||
AAAAB3NzaC1yc2EAAAADAQABAAABAQDusXfgTE4eBP50NglSzCSEGnIL6+cr6m3H6cZANO | ||
Q+P1o/W4BdtcAL3sor4iGi7SOeJgo8kweyMQrhrt6HaKGgromRiz37LQx4YIAcBi4Zd023 | ||
mO/V7Rc2Chh18mWgLSmA6ng+j37ip6452zxtv0jHAz9pJolbKBpJzbZlPN45ZCTk9ck0fS | ||
VHRl6VRSSPQcpqi65XpRf+35zNOCGCc1mAOOTmw59Q2a6A3t8mL7r91aM5q6QOQm219lct | ||
FM8O7HRJnDgmhGpnjRwE1LyKktWTbgFZ4SNWU2XqusUO07jKuSxzPumXBeU+JEtx0J1tqZ | ||
wJlpGt2R+0qN7nKnPl2+hx | ||
---- END SSH2 PUBLIC KEY ---- | ||
""" | ||
|
||
RSA_PUBLIC_KEY_RFC4716_4 = b"""\ | ||
---- BEGIN SSH2 PUBLIC KEY ---- | ||
Comment: This is my public key for use on \ | ||
servers which I don't like. | ||
AAAAB3NzaC1yc2EAAAADAQABAAABAQDusXfgTE4eBP50NglSzCSEGnIL6+cr6m3H6cZANO | ||
Q+P1o/W4BdtcAL3sor4iGi7SOeJgo8kweyMQrhrt6HaKGgromRiz37LQx4YIAcBi4Zd023 | ||
mO/V7Rc2Chh18mWgLSmA6ng+j37ip6452zxtv0jHAz9pJolbKBpJzbZlPN45ZCTk9ck0fS | ||
VHRl6VRSSPQcpqi65XpRf+35zNOCGCc1mAOOTmw59Q2a6A3t8mL7r91aM5q6QOQm219lct | ||
FM8O7HRJnDgmhGpnjRwE1LyKktWTbgFZ4SNWU2XqusUO07jKuSxzPumXBeU+JEtx0J1tqZ | ||
wJlpGt2R+0qN7nKnPl2+hx | ||
---- END SSH2 PUBLIC KEY ---- | ||
""" | ||
|
||
RSA_PUBLIC_KEY_FINGERPRINT = "6a:49:07:1c:7e:bd:d2:bd:96:25:fe:b5:74:83:ae:fd" | ||
|
||
DSA_PUBLIC_KEY_OPENSSH = b"""ssh-dss \ | ||
|
@@ -157,10 +195,20 @@ def test_key_pairs_delete_exist_boto3(): | |
"public_key,fingerprint", | ||
[ | ||
(RSA_PUBLIC_KEY_OPENSSH, RSA_PUBLIC_KEY_FINGERPRINT), | ||
(RSA_PUBLIC_KEY_RFC4716, RSA_PUBLIC_KEY_FINGERPRINT), | ||
(RSA_PUBLIC_KEY_RFC4716_1, RSA_PUBLIC_KEY_FINGERPRINT), | ||
(RSA_PUBLIC_KEY_RFC4716_2, RSA_PUBLIC_KEY_FINGERPRINT), | ||
(RSA_PUBLIC_KEY_RFC4716_3, RSA_PUBLIC_KEY_FINGERPRINT), | ||
(RSA_PUBLIC_KEY_RFC4716_4, RSA_PUBLIC_KEY_FINGERPRINT), | ||
(ED25519_PUBLIC_KEY_OPENSSH, ED25519_PUBLIC_KEY_FINGERPRINT), | ||
], | ||
ids=["rsa-openssh", "rsa-rfc4716", "ed25519"], | ||
ids=[ | ||
"rsa-openssh", | ||
"rsa-rfc4716-1", | ||
"rsa-rfc4716-2", | ||
"rsa-rfc4716-3", | ||
"rsa-rfc4716-4", | ||
"ed25519", | ||
], | ||
) | ||
def test_key_pairs_import_boto3(public_key, fingerprint): | ||
client = boto3.client("ec2", "us-west-1") | ||
|
@@ -188,6 +236,18 @@ def test_key_pairs_import_boto3(public_key, fingerprint): | |
assert kp1["KeyName"] in all_names | ||
|
||
|
||
@mock_aws | ||
def test_key_pairs_import_invalid_key(): | ||
client = boto3.client("ec2", "us-west-1") | ||
|
||
with pytest.raises(ClientError) as exc: | ||
client.import_key_pair( | ||
KeyName="sth", PublicKeyMaterial="---- BEGIN SSH2 PUBLIC KEY ----\nsth" | ||
) | ||
err = exc.value.response["Error"] | ||
assert err["Code"] == "InvalidKeyPair.Format" | ||
|
||
|
||
@mock_aws | ||
def test_key_pairs_import_exist_boto3(): | ||
client = boto3.client("ec2", "us-west-1") | ||
|