-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This feature migrates from MDS2 to MDS3.
- Loading branch information
Showing
23 changed files
with
1,107 additions
and
557 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,86 @@ | ||
package protocol | ||
|
||
import ( | ||
"crypto/sha256" | ||
"testing" | ||
|
||
"github.com/go-webauthn/webauthn/metadata" | ||
) | ||
|
||
func TestVerifyAndroidKeyFormat(t *testing.T) { | ||
type args struct { | ||
att AttestationObject | ||
clientDataHash []byte | ||
} | ||
successAttResponse0 := attestationTestUnpackResponse(t, androidKeyTestResponse0["success"]).Response.AttestationObject | ||
successClientDataHash0 := sha256.Sum256(attestationTestUnpackResponse(t, androidKeyTestResponse0["success"]).Raw.AttestationResponse.ClientDataJSON) | ||
successAttResponse1 := attestationTestUnpackResponse(t, androidKeyTestResponse1["success"]).Response.AttestationObject | ||
successClientDataHash1 := sha256.Sum256(attestationTestUnpackResponse(t, androidKeyTestResponse1["success"]).Raw.AttestationResponse.ClientDataJSON) | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
want1 []interface{} | ||
wantErr bool | ||
}{ | ||
{ | ||
"success", | ||
args{ | ||
successAttResponse0, | ||
successClientDataHash0[:], | ||
}, | ||
string(metadata.BasicFull), | ||
nil, | ||
false, | ||
}, | ||
{ | ||
"success", | ||
args{ | ||
successAttResponse1, | ||
successClientDataHash1[:], | ||
}, | ||
string(metadata.BasicFull), | ||
nil, | ||
false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, _, err := verifyAndroidKeyFormat(tt.args.att, tt.args.clientDataHash) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("verifyAndroidKeyFormat() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("verifyAndroidKeyFormat() got = %v, want %v", got, tt.want) | ||
} | ||
//if !reflect.DeepEqual(got1, tt.want1) { | ||
// t.Errorf("verifySafetyNetFormat() got1 = %v, want %v", got1, tt.want1) | ||
//} | ||
}) | ||
} | ||
} | ||
|
||
var androidKeyTestResponse0 = map[string]string{ | ||
`success`: `{ | ||
"rawId": "U5cxFNxLbU9-SAi1K7k9atYwXhghkAMbxpL__VPtBlw", | ||
"id": "U5cxFNxLbU9-SAi1K7k9atYwXhghkAMbxpL__VPtBlw", | ||
"response": { | ||
"clientDataJSON": "eyJvcmlnaW4iOiJodHRwczovL2xvY2FsaG9zdDo0NDMyOSIsImNoYWxsZW5nZSI6IjlNNWY3bGp5MVl2UWNzOE9pV1FWQ3ciLCJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0", | ||
"attestationObject": "o2NmbXRrYW5kcm9pZC1rZXlnYXR0U3RtdKNjYWxnJmNzaWdYSDBGAiEAlbQ-jtl8o9GtEstcEFH1Z_NlYsTYSn96lilEF17oEsMCIQDza5_axjn2jKZO63RlVf47DDFZbceW9b_tsh1nwOYQbmN4NWOCWQMFMIIDATCCAqegAwIBAgIBATAKBggqhkjOPQQDAjCBzjFFMEMGA1UEAww8RkFLRSBBbmRyb2lkIEtleXN0b3JlIFNvZnR3YXJlIEF0dGVzdGF0aW9uIEludGVybWVkaWF0ZSBGQUtFMTEwLwYJKoZIhvcNAQkBFiJjb25mb3JtYW5jZS10b29sc0BmaWRvYWxsaWFuY2Uub3J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