Skip to content

Commit f6713f6

Browse files
committed
Fix tests
1 parent a18d629 commit f6713f6

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
@@ -8,6 +8,7 @@ Changes to JS assets are not included here, but in [`atomic-data-browser`'s CHAN
88

99
- Add parent parameter to search endpoint which scopes a search to only the decendants of the given resource.
1010
- Bookmark endpoint now also retrieves `og:image` and `og:description` #510
11+
- Refactored Subject URLs to use `AtomicUrl`
1112

1213
## [v0.33.1] - 2022-09-25
1314

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
@@ -34,7 +34,7 @@ pub fn check_auth_signature(subject: &str, auth_header: &AuthValues) -> AtomicRe
3434
.verify(message.as_bytes(), &signature_bytes)
3535
.map_err(|_e| {
3636
format!(
37-
"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: {}",
37+
"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: '{}'",
3838
message,
3939
)
4040
})?;

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
})?;
@@ -439,7 +439,6 @@ impl Commit {
439439
.to_string()
440440
}
441441
};
442-
println!("commit subject: {}", commit_subject);
443442
let mut resource = Resource::new_instance(urls::COMMIT, store)?;
444443
resource.set_subject(commit_subject);
445444
resource.set_propval_unsafe(

lib/src/db.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ impl Storelike for Db {
216216
update_index: bool,
217217
overwrite_existing: bool,
218218
) -> AtomicResult<()> {
219-
println!("add_resource_opts {}", resource.get_subject());
220219
// This only works if no external functions rely on using add_resource for atom-like operations!
221220
// However, add_atom uses set_propvals, which skips the validation.
222221
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)