aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2021-04-16 14:41:35 +0300
committerYigit Sever2021-04-16 14:41:35 +0300
commitabe7d7e11638b5496fa89da73823701dc0f6e5d4 (patch)
tree8ecb8574b2c407804bdd9e924032254a6f792b74
parenta56a71e3971a8d0680439b8217ddee41462fd6dc (diff)
downloadgradecoin-abe7d7e11638b5496fa89da73823701dc0f6e5d4.tar.gz
gradecoin-abe7d7e11638b5496fa89da73823701dc0f6e5d4.tar.bz2
gradecoin-abe7d7e11638b5496fa89da73823701dc0f6e5d4.zip
Passing auth test
-rw-r--r--src/handlers.rs9
-rw-r--r--tests/route_tests.rs2
2 files changed, 5 insertions, 6 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index 2401c0d..ee0fbf0 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -151,7 +151,7 @@ pub async fn authenticate_user(
151 151
152 let res_json = warp::reply::json(&GradeCoinResponse { 152 let res_json = warp::reply::json(&GradeCoinResponse {
153 res: ResponseType::Error, 153 res: ResponseType::Error,
154 message: "Given IV has invalid length".to_owned(), 154 message: "Given IV has invalid length, use a 128 bit key".to_owned(),
155 }); 155 });
156 156
157 return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); 157 return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST));
@@ -176,9 +176,8 @@ pub async fn authenticate_user(
176 } 176 }
177 }; 177 };
178 178
179 println!(">>>{:?}<<<", auth_packet); 179 let mut buf = auth_packet.to_vec();
180 180 let auth_plaintext = match cipher.decrypt(&mut buf) {
181 let auth_plaintext = match cipher.decrypt_vec(&auth_packet) {
182 Ok(p) => p, 181 Ok(p) => p,
183 Err(err) => { 182 Err(err) => {
184 println!( 183 println!(
@@ -195,7 +194,7 @@ pub async fn authenticate_user(
195 } 194 }
196 }; 195 };
197 196
198 let utf8_auth_plaintext = match String::from_utf8(auth_plaintext.clone()) { 197 let utf8_auth_plaintext = match String::from_utf8(auth_plaintext.to_vec()) {
199 Ok(text) => text, 198 Ok(text) => text,
200 Err(err) => { 199 Err(err) => {
201 debug!( 200 debug!(
diff --git a/tests/route_tests.rs b/tests/route_tests.rs
index 537b3d8..f3fbb0e 100644
--- a/tests/route_tests.rs
+++ b/tests/route_tests.rs
@@ -445,7 +445,7 @@ FQIDAQAB
445 let res = warp::test::request() 445 let res = warp::test::request()
446 .method("POST") 446 .method("POST")
447 .json(&InitialAuthRequest { 447 .json(&InitialAuthRequest {
448 c: "xsF0qqyokuvOZJ4CgnW4mzfLHaTZS3vLqr7y8LFx6pdKo0XKXBJ4+Ojx8Uz6CYrQZLPy39O485BZNtYtLzcfF/03MePBNgSRM6ccVuh6hJ8UUAjv9nf93gZlnGceMP0bLKEaYRHTsgyW+s0y0ki7/CfYn3vveLDd4NVkkgFUAebcmMuAJJt0OAzSLgsQ/kww6hOOsIcIlBNlLIi0dopCUxE5h7aPqV4WyrxA/PSvE8hM8LcfYiATTa7PyinfkjCRu7hzItM/N3+h/zubI+6ht8lY4V/19WB24HnMZJdP1odAPuKbSDiyZoMvq+P7jHfWnbJxJJI7hEYlbB45MNMnFenVhzwEtIqHu6JEGhi7umDoh2zUDAXzofERkd3qNgPtV6L3hxmDX94Y8FIJ9ZdDj/EG06PXj9P3kg0Gt4t+hi+J8h+RtV+g+Pwza1kFCLA6sXoPxxhTuEGyYCYi+DYtWCOCFo2loyReg+juIQQRpSZsZmu4Ml5eEcVpD24lUWZ6yO/AL/TjA9eSU+PgSrQzNBggMWg4Pd6MubILBTI+crt/rSCKwcGBu2IDEiVTIWLCqlMW/PHL6LkLyLnnvOuP6yHKwpnlWboV9h+TSDfzs4aur1AoUnW+UuEQXvYYfVNkSPJ+dsOGHwi1LyAql3H36jX4dtESGZSINUjeiYxR8fwZdnge1Eo+sOGT3cQ+wCL9".to_owned(), 448 c: "D9OKSp4XD+niltqhoiTEyz3pTxGm5ZKYVNFPofW40M6Km7wE7FgIpfTkurBZ6tQsG/rYPRsd6C/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