MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / test_http_integration

Function test_http_integration

chirpstack/src/api/application.rs:2069–2204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2067
2068 #[tokio::test]
2069 async fn test_http_integration() {
2070 let _guard = test::prepare().await;
2071 let app = get_application().await;
2072 let u = get_user().await;
2073 let service = Application::new(RequestValidator::new());
2074
2075 // create
2076 let create_req = get_request(
2077 &u.id,
2078 api::CreateHttpIntegrationRequest {
2079 integration: Some(api::HttpIntegration {
2080 application_id: app.id.to_string(),
2081 headers: [("Foo".to_string(), "Bar".to_string())]
2082 .iter()
2083 .cloned()
2084 .collect(),
2085 encoding: api::Encoding::Json.into(),
2086 event_endpoint_url: "http://example.com".into(),
2087 }),
2088 },
2089 );
2090 let _ = service.create_http_integration(create_req).await.unwrap();
2091
2092 // get
2093 let get_req = get_request(
2094 &u.id,
2095 api::GetHttpIntegrationRequest {
2096 application_id: app.id.to_string(),
2097 },
2098 );
2099 let get_resp = service.get_http_integration(get_req).await.unwrap();
2100 let get_resp = get_resp.get_ref();
2101 assert_eq!(
2102 Some(api::HttpIntegration {
2103 application_id: app.id.to_string(),
2104 headers: [("Foo".to_string(), "Bar".to_string())]
2105 .iter()
2106 .cloned()
2107 .collect(),
2108 encoding: api::Encoding::Json.into(),
2109 event_endpoint_url: "http://example.com".into(),
2110 }),
2111 get_resp.integration
2112 );
2113
2114 // update
2115 let update_req = get_request(
2116 &u.id,
2117 api::UpdateHttpIntegrationRequest {
2118 integration: Some(api::HttpIntegration {
2119 application_id: app.id.to_string(),
2120 headers: [("Foo".to_string(), "Bas".to_string())]
2121 .iter()
2122 .cloned()
2123 .collect(),
2124 encoding: api::Encoding::Protobuf.into(),
2125 event_endpoint_url: "http://example.org".into(),
2126 }),

Callers

nothing calls this directly

Calls 13

prepareFunction · 0.85
get_applicationFunction · 0.85
to_stringMethod · 0.80
iterMethod · 0.80
unwrapMethod · 0.80
get_http_integrationMethod · 0.80
list_integrationsMethod · 0.80
get_userFunction · 0.70
get_requestFunction · 0.70

Tested by

no test coverage detected