Skip to content

Commit

Permalink
Update test to avoid reading fiel
Browse files Browse the repository at this point in the history
  • Loading branch information
durch committed Dec 25, 2016
1 parent 5f309dd commit 490b1b1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ impl RSAKey {
Ok(RSAKey { key: pkey })
}

pub fn from_str(pkey: &str) -> Result<Self, JwtErr> {
Ok(RSAKey { key: PKey::private_key_from_pem(pkey.as_bytes())? })
}

fn read_keyfile(keyfile: &str) -> Result<PKey, JwtErr> {
let mut f = File::open(keyfile)?;
let mut buffer = Vec::new();
Expand Down Expand Up @@ -190,7 +194,7 @@ fn test_sign() {
serialize: String
}

let rsa_key = match RSAKey::from_pem("random_rsa_for_testing") {
let rsa_key = match RSAKey::from_str("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEApbqWApvg28npX4N0WlP+6gRAvOsBqDZjqEilUfwyjYxaXecU87dOVN31jBBcEXffrPWX9njntWRKF+WwDvm6xi5rSlhbKU/SlTFiMPJx/r9789UpWPKmkDncRQVzBm5NFeYTRAu870SgF9Z2DQC46utGWEBkRYsKs+C5jo7vBse50xshCS6XiWK+7UQlJyV+egOIPwFMMXAmhqfVhSRnzEz1QwoJJrakzenNgiAcWhSQ4MBKtuOlkQse1mWEQFQ0yYx0kwMogNQMK70wdRf+STdGZyIJHGYfvZBrEZlpPufB6FPOA+LmG1YCf3276DNb6hmauTa5q+8j24FseUkdywIDAQABAoIBAFpeW94gUYSHnRHQBGoc0yuYFhTtsIGg5saklkEWXBqDJeN+VhZvJe9w+KvfX9TGoNkXMj3bv71RanWNcWs5EXdvaGGpvEvSkul3fCtkiHR4xYY3/cvaxKhwZIPebNJc4vvF8UtxexydNw7IiqacdjjjAgCtW//vyW48Y/IwTnZLHQ0cdY/OqiKHB1O5IdtdVP4zQJ5TozA+7TcgZjcBHTBnBWOG/viFdD3MVAGPiodeMcHILvHUpoxqAw43J9OZVArCU1OuT+GJN/yCkbtsJQkzRi8FXPNh/5D31lJr+Pgb7MPjOWca3u9MQjVO9VWE4nqGQ+/h8MdJyHJm1m7odwECgYEA+5IZtdstqd8cszACdPQgVntcc8P9mkmf5B1Ig/FtpqfzjXjSw/oyn5WT0SunPUSIHXT5LVWsUrJU+XxrQnZ1qlYSSMxfY+aQKvhxU/5z53PxEMq0rJEEt/YG6Gzf1W9b5wPa5cJFY1qIsBM3q7o+ThemSUjdXGd8fYb3IDXjKhsCgYEAqKWSgZ1Eig2jrPzPJQU8ZlJhK9nx+b5OeO0zUwOWDuZPgbuSFlsTi7OL5pNPHv3f8Tb7bs031jcFWdhUEw/V48RLek3DUd7p5LZmwHQic91o8XQ6Yp0nYyxn0VAQFwT7DqTb9PZWdiEsVGrj0P4lQEIkA2WlwLChEnFQhjgPFhECgYA0d0/tYXywhNuTc1vP0Go+HxQ1AJcPanNyO7k3604XB8f/pUcvoCqWpbdiVFxYpsZMfmzJS6jYxmB6d7xW7CW2FKVTkWwDhb5jd9UK03KQvtlzyxLLOqNlSmY+axZziPn9wAwTBuU5x1PihN+DbSA5YS1I821XLC4Gb/NyQErUKQKBgHA6HpCac23bPbx0T/S200bUM03XLyue9OGMF8d6b3Vi1i3jAIhX+13QEZ1TEifxkgEXMaK+dhXbb3gmeWxl8VQs4H13Gi91Q/irWR1hKzwnbxqe2eud4QQiHMQxn0NyUQ+hra4J7+eUk8dpikkdlvR4DzcjgXYFFGsNdSScUY3BAoGBAOPQOwUekXEObbBVD2ZwnJAPe0A5YDwMgvv8QZehEx7Y9OF/fcEbqR8khzR93btLMbEZ+LkBw0oPcXDhNhxsGXUyRRnAAr6gX8cX8rhgpUmvLFoTBNHNsI5PlkWNQxRnuESumOsbasF/4BHrH33bZnNtBaYH9YfWshR+KdtBr8IM\n-----END RSA PRIVATE KEY-----") {
Ok(x) => x,
Err(e) => panic!("{}", e)
};
Expand Down

0 comments on commit 490b1b1

Please sign in to comment.