1
0
Fork 0

Adding upstream version 0.0.22.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-08 18:41:54 +02:00
parent 2f814b513a
commit b06d3acde8
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
190 changed files with 61565 additions and 0 deletions

View file

@ -0,0 +1,383 @@
#![allow(non_snake_case)]
use {
icann_rdap_client::{
http::{create_client, ClientConfig},
rdap::{rdap_request, QueryType},
},
icann_rdap_common::response::Rfc9083Error,
icann_rdap_srv::storage::{
data::{AutnumId, DomainId, EntityId, NetworkId, NetworkIdType},
StoreOps,
},
};
use crate::test_jig::SrvTestJig;
#[tokio::test]
async fn GIVEN_bootstrap_with_less_specific_domain_WHEN_query_domain_THEN_status_code_is_redirect()
{
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_domain_err(
&DomainId::builder().ldh_name("example").build(),
&Rfc9083Error::redirect().url("https://example.net/").build(),
)
.await
.expect("add domain redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::domain("foo.example").expect("invalid domain name");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert!(response.rdap.is_redirect());
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://example.net/domain/foo.example"
);
}
#[tokio::test]
#[should_panic]
async fn GIVEN_bootstrap_with_no_less_specific_domain_WHEN_query_domain_THEN_should_panic() {
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_domain_err(
&DomainId::builder().ldh_name("no_example").build(),
&Rfc9083Error::redirect().url("https://example.net").build(),
)
.await
.expect("add domain redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::domain("foo.example").expect("invalid domain name");
let response = rdap_request(&test_srv.rdap_base, &query, &client).await;
// THEN
response.expect("this should be a 404"); // SHOULD PANIC
}
#[tokio::test]
async fn GIVEN_bootstrap_with_less_specific_ns_WHEN_query_ns_THEN_status_code_is_redirect() {
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_domain_err(
&DomainId::builder().ldh_name("example").build(),
&Rfc9083Error::redirect().url("https://example.net/").build(),
)
.await
.expect("add domain redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::ns("ns.foo.example").expect("invalid nameserver");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert!(response.rdap.is_redirect());
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://example.net/nameserver/ns.foo.example"
);
}
#[tokio::test]
#[should_panic]
async fn GIVEN_bootstrap_with_no_less_specific_ns_WHEN_query_ns_THEN_should_panic() {
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_domain_err(
&DomainId::builder().ldh_name("no_example").build(),
&Rfc9083Error::redirect().url("https://example.net").build(),
)
.await
.expect("add domain redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::ns("ns.foo.example").expect("invalid nameserver");
let response = rdap_request(&test_srv.rdap_base, &query, &client).await;
// THEN
response.expect("this should be a 404"); // SHOULD PANIC
}
#[tokio::test]
async fn GIVEN_bootstrap_with_less_specific_ip_WHEN_query_ip_THEN_status_code_is_redirect() {
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_network_err(
&NetworkId::builder()
.network_id(NetworkIdType::Cidr(ipnet::IpNet::V4(
"10.0.0.0/8".parse().expect("parsing ipnet"),
)))
.build(),
&Rfc9083Error::redirect().url("https://example.net/").build(),
)
.await
.expect("adding network redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::ipv4cidr("10.0.0.0/24").expect("invalid CIDR");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert!(response.rdap.is_redirect());
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://example.net/ip/10.0.0.0/24"
);
}
#[tokio::test]
#[should_panic]
async fn GIVEN_bootstrap_with_no_less_specific_ip_WHEN_query_ip_THEN_should_panic() {
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_network_err(
&NetworkId::builder()
.network_id(NetworkIdType::Cidr(ipnet::IpNet::V4(
"10.0.0.0/8".parse().expect("parsing ipnet"),
)))
.build(),
&Rfc9083Error::redirect().url("https://example.net").build(),
)
.await
.expect("adding network redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::ipv4cidr("11.0.0.0/24").expect("invalid CIDR");
let response = rdap_request(&test_srv.rdap_base, &query, &client).await;
// THEN
response.expect("this should be 404"); // SHOLD PANIC
}
#[tokio::test]
async fn GIVEN_bootstrap_with_less_specific_autnum_WHEN_query_autnum_THEN_status_code_is_redirect()
{
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_autnum_err(
&AutnumId::builder()
.start_autnum(700)
.end_autnum(800)
.build(),
&Rfc9083Error::redirect().url("https://example.net/").build(),
)
.await
.expect("adding autnum redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::autnum("AS710").expect("invalid autnum");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert!(response.rdap.is_redirect());
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://example.net/autnum/710"
);
}
#[tokio::test]
#[should_panic]
async fn GIVEN_bootstrap_with_no_less_specific_autnum_WHEN_query_autnum_THEN_should_panic() {
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_autnum_err(
&AutnumId::builder()
.start_autnum(700)
.end_autnum(800)
.build(),
&Rfc9083Error::redirect().url("https://example.net").build(),
)
.await
.expect("adding autnum redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::autnum("AS1000").expect("invalid autnum");
let response = rdap_request(&test_srv.rdap_base, &query, &client).await;
// THEN
response.expect("this should be 404"); // SHOLD PANIC
}
#[tokio::test]
async fn GIVEN_bootstrap_with_specific_tag_WHEN_query_entity_THEN_status_code_is_redirect() {
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_entity_err(
&EntityId::builder().handle("-ARIN").build(),
&Rfc9083Error::redirect().url("https://example.net/").build(),
)
.await
.expect("adding entity redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::Entity("foo-ARIN".to_string());
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert!(response.rdap.is_redirect());
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://example.net/entity/foo-ARIN"
);
}
#[tokio::test]
async fn GIVEN_bootstrap_with_specific_tag_lowercase_WHEN_query_entity_THEN_status_code_is_redirect(
) {
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_entity_err(
&EntityId::builder().handle("-ARIN").build(),
&Rfc9083Error::redirect().url("https://example.net/").build(),
)
.await
.expect("adding entity redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::Entity("foo-arin".to_string());
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert!(response.rdap.is_redirect());
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://example.net/entity/foo-arin"
);
}
#[tokio::test]
#[should_panic]
async fn GIVEN_bootstrap_with_no_specific_tag_WHEN_query_entity_THEN_should_panic() {
// GIVEN
let test_srv = SrvTestJig::new_bootstrap().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_entity_err(
&EntityId::builder().handle("-CLAUCA").build(),
&Rfc9083Error::redirect().url("https://example.net").build(),
)
.await
.expect("adding entity redirect");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::Entity("foo-arin".to_string());
let response = rdap_request(&test_srv.rdap_base, &query, &client).await;
// THEN
response.expect("this should be 404"); // SHOLD PANIC
}

View file

@ -0,0 +1,125 @@
#![allow(non_snake_case)]
use {
icann_rdap_client::{
http::{create_client, ClientConfig},
rdap::{rdap_request, QueryType},
RdapClientError,
},
icann_rdap_common::response::Domain,
icann_rdap_srv::storage::{CommonConfig, StoreOps},
};
use crate::test_jig::SrvTestJig;
#[tokio::test]
async fn GIVEN_server_with_domain_WHEN_query_domain_THEN_status_code_200() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_domain(&Domain::builder().ldh_name("foo.example").build())
.await
.expect("add domain in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::domain("foo.example").expect("invalid domain name");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 200);
}
#[tokio::test]
async fn GIVEN_server_with_idn_WHEN_query_domain_THEN_status_code_200() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_domain(
&Domain::idn()
.unicode_name("café.example")
.ldh_name("cafe.example")
.build(),
)
.await
.expect("add domain in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::domain("café.example").expect("invalid domain name");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 200);
}
#[tokio::test]
async fn GIVEN_server_with_domain_and_search_disabled_WHEN_query_domain_THEN_status_code_501() {
// GIVEN
let common_config = CommonConfig::builder()
.domain_search_by_name_enable(false)
.build();
let test_srv = SrvTestJig::new_common_config(common_config).await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_domain(&Domain::builder().ldh_name("foo.example").build())
.await
.expect("add domain in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::DomainNameSearch("foo.*".to_string());
let response = rdap_request(&test_srv.rdap_base, &query, &client).await;
// THEN
let RdapClientError::Client(error) = response.expect_err("not an error response") else {
panic!("the error was not an HTTP error")
};
assert_eq!(error.status().expect("no status code"), 501);
}
#[tokio::test]
async fn GIVEN_server_with_domain_and_search_enabled_WHEN_query_domain_THEN_status_code_200() {
// GIVEN
let common_config = CommonConfig::builder()
.domain_search_by_name_enable(true)
.build();
let test_srv = SrvTestJig::new_common_config(common_config).await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_domain(&Domain::builder().ldh_name("foo.example").build())
.await
.expect("add domain in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::DomainNameSearch("foo.*".to_string());
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 200);
}

View file

@ -0,0 +1,4 @@
mod bootstrap;
mod domain;
mod redirect;
mod srvhelp;

View file

@ -0,0 +1,315 @@
#![allow(non_snake_case)]
use {
icann_rdap_client::{
http::{create_client, ClientConfig},
rdap::{rdap_request, QueryType},
},
icann_rdap_common::response::{Link, Notice, NoticeOrRemark, Rfc9083Error},
icann_rdap_srv::storage::{
data::{AutnumId, DomainId, EntityId, NameserverId, NetworkId, NetworkIdType},
StoreOps,
},
};
use crate::test_jig::SrvTestJig;
#[tokio::test]
async fn GIVEN_domain_error_with_first_link_href_WHEN_query_THEN_status_code_is_redirect() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_domain_err(
&DomainId {
ldh_name: "foo.example".to_string(),
unicode_name: None,
},
&Rfc9083Error::builder()
.error_code(307)
.notice(Notice(
NoticeOrRemark::builder()
.links(vec![Link::builder()
.href("https://other.example.com")
.value("https://other.example.com")
.rel("about")
.build()])
.build(),
))
.build(),
)
.await
.expect("add redirect in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::domain("foo.example").expect("invalid domain name");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 307);
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://other.example.com"
);
}
#[tokio::test]
async fn GIVEN_nameserver_error_with_first_link_href_WHEN_query_THEN_status_code_is_redirect() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_nameserver_err(
&NameserverId {
ldh_name: "ns.foo.example".to_string(),
unicode_name: None,
},
&Rfc9083Error::builder()
.error_code(307)
.notice(Notice(
NoticeOrRemark::builder()
.links(vec![Link::builder()
.href("https://other.example.com")
.value("https://other.example.com")
.rel("about")
.build()])
.build(),
))
.build(),
)
.await
.expect("add redirect in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::ns("ns.foo.example").expect("invalid nameserver");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 307);
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://other.example.com"
);
}
#[tokio::test]
async fn GIVEN_entity_error_with_first_link_href_WHEN_query_THEN_status_code_is_redirect() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_entity_err(
&EntityId {
handle: "foo".to_string(),
},
&Rfc9083Error::builder()
.error_code(307)
.notice(Notice(
NoticeOrRemark::builder()
.links(vec![Link::builder()
.href("https://other.example.com")
.value("https://other.example.com")
.rel("about")
.build()])
.build(),
))
.build(),
)
.await
.expect("add redirect in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::Entity("foo".to_string());
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 307);
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://other.example.com"
);
}
#[tokio::test]
async fn GIVEN_autnum_error_with_first_link_href_WHEN_query_THEN_status_code_is_redirect() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_autnum_err(
&AutnumId {
start_autnum: 700,
end_autnum: 710,
},
&Rfc9083Error::builder()
.error_code(307)
.notice(Notice(
NoticeOrRemark::builder()
.links(vec![Link::builder()
.href("https://other.example.com")
.value("https://other.example.com")
.rel("about")
.build()])
.build(),
))
.build(),
)
.await
.expect("add redirect in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::autnum("700").expect("invalid autnum");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 307);
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://other.example.com"
);
}
#[tokio::test]
async fn GIVEN_network_cidr_error_with_first_link_href_WHEN_query_THEN_status_code_is_redirect() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_network_err(
&NetworkId {
network_id: NetworkIdType::Cidr("10.0.0.0/16".parse().expect("parsing cidr")),
},
&Rfc9083Error::builder()
.error_code(307)
.notice(Notice(
NoticeOrRemark::builder()
.links(vec![Link::builder()
.href("https://other.example.com")
.value("https://other.example.com")
.rel("about")
.build()])
.build(),
))
.build(),
)
.await
.expect("add redirect in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::ipv4("10.0.0.1").expect("invalid IP address");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 307);
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://other.example.com"
);
}
#[tokio::test]
async fn GIVEN_network_addrs_error_with_first_link_href_WHEN_query_THEN_status_code_is_redirect() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
tx.add_network_err(
&NetworkId {
network_id: NetworkIdType::Range {
start_address: "10.0.0.0".to_string(),
end_address: "10.0.0.255".to_string(),
},
},
&Rfc9083Error::builder()
.error_code(307)
.notice(Notice(
NoticeOrRemark::builder()
.links(vec![Link::builder()
.href("https://other.example.com")
.value("https://other.example.com")
.rel("about")
.build()])
.build(),
))
.build(),
)
.await
.expect("add redirect in tx");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::ipv4("10.0.0.1").expect("invalid IP address");
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 307);
assert_eq!(
response
.http_data
.location
.as_ref()
.expect("no location header information"),
"https://other.example.com"
);
}

View file

@ -0,0 +1,77 @@
#![allow(non_snake_case)]
use {
icann_rdap_client::{
http::{create_client, ClientConfig},
rdap::{rdap_request, QueryType},
},
icann_rdap_common::response::{Help, Notice, NoticeOrRemark},
icann_rdap_srv::storage::StoreOps,
};
use crate::test_jig::SrvTestJig;
#[tokio::test]
async fn GIVEN_server_with_default_help_WHEN_query_help_THEN_status_code_200() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
let srvhelp = Help::builder()
.notice(Notice(
NoticeOrRemark::builder()
.description_entry("foo".to_string())
.build(),
))
.build();
tx.add_srv_help(&srvhelp, None)
.await
.expect("adding srv help");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::Help;
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 200);
}
#[tokio::test]
async fn GIVEN_server_with_host_help_WHEN_query_help_THEN_status_code_200() {
// GIVEN
let test_srv = SrvTestJig::new().await;
let mut tx = test_srv.mem.new_tx().await.expect("new transaction");
let srvhelp = Help::builder()
.notice(Notice(
NoticeOrRemark::builder()
.description_entry("foo".to_string())
.build(),
))
.build();
tx.add_srv_help(&srvhelp, Some("foo.example.com"))
.await
.expect("adding srv help");
tx.commit().await.expect("tx commit");
// WHEN
let client_config = ClientConfig::builder()
.https_only(false)
.follow_redirects(false)
.host(reqwest::header::HeaderValue::from_static("foo.example.com"))
.build();
let client = create_client(&client_config).expect("creating client");
let query = QueryType::Help;
let response = rdap_request(&test_srv.rdap_base, &query, &client)
.await
.expect("quering server");
// THEN
assert_eq!(response.http_data.status_code, 200);
}