diff options
author | alpaylan | 2021-04-14 02:42:04 +0300 |
---|---|---|
committer | alpaylan | 2021-04-14 02:42:04 +0300 |
commit | c1f4287b167aeb69e26ff6307be4a76a124bd99b (patch) | |
tree | d16ebfe7690c9b3e46f4c946b9257684ebc323e6 | |
parent | d4646efc091a0bda018244f451e68c5798c62462 (diff) | |
download | gradecoin-c1f4287b167aeb69e26ff6307be4a76a124bd99b.tar.gz gradecoin-c1f4287b167aeb69e26ff6307be4a76a124bd99b.tar.bz2 gradecoin-c1f4287b167aeb69e26ff6307be4a76a124bd99b.zip |
finished auth request testing.
-rw-r--r-- | tests/schema_tests.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/schema_tests.rs b/tests/schema_tests.rs index 7fbbba0..e58af29 100644 --- a/tests/schema_tests.rs +++ b/tests/schema_tests.rs | |||
@@ -236,7 +236,7 @@ mod tests { | |||
236 | #[test] | 236 | #[test] |
237 | fn metu_id_deserialize_correctly() { | 237 | fn metu_id_deserialize_correctly() { |
238 | let expected_metu_id = MetuId::new ("e254275".to_owned()).unwrap(); | 238 | let expected_metu_id = MetuId::new ("e254275".to_owned()).unwrap(); |
239 | let data = r#"{"{"id":"e254275"}"#; | 239 | let data = r#"{"id":"e254275"}"#; |
240 | let metu_id: MetuId = serde_json::from_str(data).unwrap(); | 240 | let metu_id: MetuId = serde_json::from_str(data).unwrap(); |
241 | 241 | ||
242 | assert_eq!(metu_id, expected_metu_id); | 242 | assert_eq!(metu_id, expected_metu_id); |
@@ -244,11 +244,34 @@ mod tests { | |||
244 | 244 | ||
245 | #[test] | 245 | #[test] |
246 | fn auth_request_serialize_correctly() { | 246 | fn auth_request_serialize_correctly() { |
247 | let auth_request = AuthRequest { | ||
248 | student_id: "e254275".to_owned(), | ||
249 | public_key: "public_key".to_owned() | ||
250 | }; | ||
247 | 251 | ||
252 | assert_tokens( | ||
253 | &auth_request, | ||
254 | &[ | ||
255 | Token::Struct{name: "AuthRequest", len: 2}, | ||
256 | Token::String("student_id"), | ||
257 | Token::String("e254275"), | ||
258 | Token::String("public_key"), | ||
259 | Token::String("public_key"), | ||
260 | Token::StructEnd, | ||
261 | ] | ||
262 | ) | ||
248 | } | 263 | } |
249 | 264 | ||
250 | #[test] | 265 | #[test] |
251 | fn auth_request_deserialize_correctly() { | 266 | fn auth_request_deserialize_correctly() { |
267 | let expected_auth_request = AuthRequest { | ||
268 | student_id: "e254275".to_owned(), | ||
269 | public_key: "public_key".to_owned() | ||
270 | }; | ||
271 | let data = r#"{"student_id":"e254275","public_key":"public_key"}"#; | ||
272 | let auth_request: AuthRequest = serde_json::from_str(data).unwrap(); | ||
273 | |||
274 | assert_eq!(auth_request, expected_auth_request); | ||
252 | 275 | ||
253 | } | 276 | } |
254 | 277 | ||