<commit_before>package keys

import (
	"bufio"
	//	"golang.org/x/crypto/ssh"
	"io/ioutil"
	"os"
	//	"fmt"
	"testing"
)

func checke(t *testing.T, e error) {
	if e != nil {
		t.Error(e)
	}
}

func assertStringsEquals(t *testing.T, s1, s2 string) {
	if s1 != s2 {
		t.Logf("Expected [%s] but got [%s]", s1, s2)
		t.Fail()
	}
}

func TestSSHPublicKeyParsing(t *testing.T) {
	path := "test-data/public-keys"
	keys, err := ioutil.ReadDir(path)
	checke(t, err)

	for _, key := range keys {
		kp := path + "/" + key.Name()
		t.Run(key.Name(), func(t *testing.T) {
			k := Read(kp)
			if k == nil {
				t.Error("Failed to parse " + kp)
			}
		})
	}
}

func TestSSHPrivateKeyParse(t *testing.T) {
	key := Read("test-data/rsa")
	rsa := key.(*SSHPublicKey)
	assertStringsEquals(t, "ssh-rsa", rsa.Type)
	assertStringsEquals(t, "<KEY>", rsa.PublicKeyString)
}

func TestSSHPublicKeyParse(t *testing.T) {
	t.Run("RSA", func(t *testing.T) {
		key := Read("test-data/rsa.pub")
		if key == nil {
			t.Error("Failed to parse RSA")
		}
		rsa := key.(*SSHPublicKey)
		assertStringsEquals(t, "ssh-rsa", rsa.Type)
		assertStringsEquals(t, "dewey@Fly<PASSWORD>der", rsa.Comments[0])
		assertStringsEquals(t, "<KEY>", rsa.PublicKeyString)<commit_msg>Expand the private key tests<commit_after>package keys

import (
	"bufio"
	//	"golang.org/x/crypto/ssh"
	"io/ioutil"
	"os"
	//	"fmt"
	"testing"
)

func checke(t *testing.T, e error) {
	if e != nil {
		t.Error(e)
	}
}

func assertStringsEquals(t *testing.T, s1, s2 string) {
	if s1 != s2 {
		t.Logf("Expected [%s] but got [%s]", s1, s2)
		t.Fail()
	}
}

func TestSSHPublicKeyParsing(t *testing.T) {
	path := "test-data/public-keys"
	keys, err := ioutil.ReadDir(path)
	checke(t, err)

	for _, key := range keys {
		kp := path + "/" + key.Name()
		t.Run(key.Name(), func(t *testing.T) {
			k := Read(kp)
			if k == nil {
				t.Error("Failed to parse " + kp)
			}
		})
	}
}

func TestSSHPrivateKeyParse(t *testing.T) {
	t.Run("RSA", func(t *testing.T) {
		key := Read("test-data/rsa")
		if key == nil {
			t.Error("Failed to parse RSA")
		}
		rsa := key.(*SSHPublicKey)
		assertStringsEquals(t, "ssh-rsa", rsa.Type)
		assertStringsEquals(t, "<KEY>", rsa.PublicKeyString)
	})

	t.Run("DSS", func(t *testing.T) {
		key := Read("test-data/dss")
		if key == nil {
			t.Error("Failed to parse DSS")
		}
		dss := key.(*SSHPublicKey)
		assertStringsEquals(t, "ssh-dss", dss.Type)
		assertStringsEquals(t, "<KEY>=", dss.PublicKeyString)
	})
}

func TestSSHPublicKeyParse(t *testing.T) {
	t.Run("RSA", func(t *testing.T) {
		key := Read("test-data/rsa.pub")
		if key == nil {
			t.Error("Failed to parse RSA")
		}
		rsa := key.(*SSHPublicKey)
		assertStringsEquals(t, "ssh-rsa", rsa.Type)
		assertStringsEquals(t, "dewey@FlynnRyder", rsa.Comments[0])
		assertStringsEquals(t, "<KEY>", rsa.PublicKeyString)
{'fraction_non_alphanumeric': 0.1937544357700497, 'fraction_numerical': 0.0049680624556423, 'mean_word_length': 3.621311475409836, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5583779', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1206, 'n_words': 239}