Skip to content

Commit 780e663

Browse files
committed
Fix tests
1 parent 1609cc2 commit 780e663

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain
2323
- `Store::all_resources` returns `Iterator` instead of `Vec` #522 #487
2424
- Change authentication order #525
2525
- Fix cookie subject check #525
26+
- Refactored Subject URLs to use `AtomicUrl`
2627

2728
## [v0.33.1] - 2022-09-25
2829

lib/src/agents.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ impl Agent {
5252
private_key: &str,
5353
) -> AtomicResult<Agent> {
5454
let keypair = generate_public_key(private_key);
55-
println!("server url: {}", store.get_server_url());
5655
let subject = store
5756
.get_server_url()
5857
.url()

lib/src/authentication.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn check_auth_signature(subject: &str, auth_header: &AuthValues) -> AtomicRe
3535
.verify(message.as_bytes(), &signature_bytes)
3636
.map_err(|_e| {
3737
format!(
38-
"Incorrect signature for auth headers. This could be due to an error during signing or serialization of the commit. Compare this to the serialized message in the client: {}",
38+
"Incorrect signature for auth headers. This could be due to an error during signing or serialization of the commit. Compare this to the serialized message in the client: '{}'",
3939
message,
4040
)
4141
})?;

lib/src/commit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl Commit {
113113
.verify(stringified_commit.as_bytes(), &signature_bytes)
114114
.map_err(|_e| {
115115
format!(
116-
"Incorrect signature for Commit. This could be due to an error during signing or serialization of the commit. Compare this to the serialized commit in the client: {}",
116+
"Incorrect signature for Commit. This could be due to an error during signing or serialization of the commit. Compare this to the serialized commit in the client: '{}'",
117117
stringified_commit,
118118
)
119119
})?;
@@ -443,7 +443,6 @@ impl Commit {
443443
.to_string()
444444
}
445445
};
446-
println!("commit subject: {}", commit_subject);
447446
let mut resource = Resource::new_instance(urls::COMMIT, store)?;
448447
resource.set_subject(commit_subject);
449448
resource.set_propval_unsafe(

lib/src/db.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ impl Storelike for Db {
262262
update_index: bool,
263263
overwrite_existing: bool,
264264
) -> AtomicResult<()> {
265-
println!("add_resource_opts {}", resource.get_subject());
266265
// This only works if no external functions rely on using add_resource for atom-like operations!
267266
// However, add_atom uses set_propvals, which skips the validation.
268267
let existing = self.get_propvals(resource.get_subject()).ok();

server/src/tests.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ use clap::StructOpt;
1717

1818
/// Returns the request with signed headers. Also adds a json-ad accept header - overwrite this if you need something else.
1919
fn build_request_authenticated(path: &str, appstate: &AppState) -> TestRequest {
20-
let url = format!("{}{}", appstate.store.get_server_url(), path);
20+
// remove last slash
21+
let base = appstate.store.get_server_url().to_string();
22+
let url = format!("{}{}", base.trim_end_matches('/'), path);
2123
let headers = atomic_lib::client::get_authentication_headers(
2224
&url,
2325
&appstate.store.get_default_agent().unwrap(),
@@ -70,7 +72,6 @@ async fn server_tests() {
7072
let resp = test::call_service(&app, req.to_request()).await;
7173
let is_success = resp.status().is_success();
7274
let body = get_body(resp);
73-
println!("{:?}", body);
7475
assert!(is_success);
7576
assert!(body.as_str().contains("html"));
7677

@@ -102,7 +103,7 @@ async fn server_tests() {
102103

103104
// Should 401 (Unauthorized)
104105
let req =
105-
test::TestRequest::with_uri("properties").insert_header(("Accept", "application/ad+json"));
106+
test::TestRequest::with_uri("/properties").insert_header(("Accept", "application/ad+json"));
106107
let resp = test::call_service(&app, req.to_request()).await;
107108
assert_eq!(
108109
resp.status().as_u16(),
@@ -111,7 +112,7 @@ async fn server_tests() {
111112
);
112113

113114
// Get JSON-AD
114-
let req = build_request_authenticated("properties", &appstate);
115+
let req = build_request_authenticated("/properties", &appstate);
115116
let resp = test::call_service(&app, req.to_request()).await;
116117
let body = get_body(resp);
117118
println!("DEBUG: {:?}", body);
@@ -122,7 +123,7 @@ async fn server_tests() {
122123
);
123124

124125
// Get JSON-LD
125-
let req = build_request_authenticated("properties", &appstate)
126+
let req = build_request_authenticated("/properties", &appstate)
126127
.insert_header(("Accept", "application/ld+json"));
127128
let resp = test::call_service(&app, req.to_request()).await;
128129
assert!(resp.status().is_success(), "setup not returning JSON-LD");
@@ -133,7 +134,7 @@ async fn server_tests() {
133134
);
134135

135136
// Get turtle
136-
let req = build_request_authenticated("properties", &appstate)
137+
let req = build_request_authenticated("/properties", &appstate)
137138
.insert_header(("Accept", "text/turtle"));
138139
let resp = test::call_service(&app, req.to_request()).await;
139140
assert!(resp.status().is_success());
@@ -145,7 +146,7 @@ async fn server_tests() {
145146

146147
// Get Search
147148
// Does not test the contents of the results - the index isn't built at this point
148-
let req = build_request_authenticated("search?q=setup", &appstate);
149+
let req = build_request_authenticated("/search?q=setup", &appstate);
149150
let resp = test::call_service(&app, req.to_request()).await;
150151
assert!(resp.status().is_success());
151152
let body = get_body(resp);
@@ -156,7 +157,7 @@ async fn server_tests() {
156157
);
157158
}
158159

159-
/// Gets the body from the response as a String. Why doen't actix provide this?
160+
/// Gets the body from the response as a String. Why doesn't actix provide this?
160161
fn get_body(resp: ServiceResponse) -> String {
161162
let boxbody = resp.into_body();
162163
let bytes = boxbody.try_into_bytes().unwrap();

0 commit comments

Comments
 (0)