This repository was archived by the owner on Aug 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration_tests_ready.rs
More file actions
136 lines (116 loc) · 3.06 KB
/
integration_tests_ready.rs
File metadata and controls
136 lines (116 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
use axum::{
body::Body,
http::{Request, StatusCode},
Router,
};
use tower::ServiceExt;
use serde_json::json;
fn app() -> Router {
flatly_backend::app() // или другой путь, если app инициализируется иначе
}
#[tokio::test]
async fn test_register_user() {
let app = app();
let payload = json!({
"email": "test@example.com",
"password": "securepassword123",
"full_name": "Test User",
"phone": "+1234567890"
});
let response = app
.oneshot(
Request::builder()
.method("POST")
.uri("/api/auth/register")
.header("Content-Type", "application/json")
.body(Body::from(payload.to_string()))
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::CREATED);
}
#[tokio::test]
async fn test_login_user() {
let app = app();
let payload = json!({
"email": "test@example.com",
"password": "securepassword123"
});
let response = app
.oneshot(
Request::builder()
.method("POST")
.uri("/api/auth/login")
.header("Content-Type", "application/json")
.body(Body::from(payload.to_string()))
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK);
}
#[tokio::test]
async fn test_refresh_token_unauthorized() {
let app = app();
let payload = json!({
"refresh_token": "invalid.token.here"
});
let response = app
.oneshot(
Request::builder()
.method("POST")
.uri("/api/auth/refresh")
.header("Content-Type", "application/json")
.body(Body::from(payload.to_string()))
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
}
#[tokio::test]
async fn test_get_amenities() {
let app = app();
let response = app
.oneshot(
Request::builder()
.method("GET")
.uri("/api/amenities")
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK);
}
#[tokio::test]
async fn test_get_properties() {
let app = app();
let response = app
.oneshot(
Request::builder()
.method("GET")
.uri("/api/properties")
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK);
}
#[tokio::test]
async fn test_health_check() {
let app = app();
let response = app
.oneshot(
Request::builder()
.method("GET")
.uri("/health")
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK);
}