commit 972a52fb2def0270ceec764f8945cfa1949d327b
parent 25425e4d21ed996237bd20fe78706af31003379f
Author: MTRNord <mtrnord1@gmail.com>
Date: Tue, 30 Aug 2022 21:28:56 +0200
Set server ip to work with the github action
Diffstat:
3 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/.github/workflows/test_known.yml b/.github/workflows/test_known.yml
@@ -45,8 +45,6 @@ jobs:
--health-retries 50
--health-interval 30s
--health-timeout 30s
- ports:
- - 8008:8008
steps:
- uses: actions/checkout@v3
@@ -57,19 +55,20 @@ jobs:
apt-get clean
- name: Register get_nonce
id: get_nonce
- run: echo "::set-output nonce=$(curl http://localhost:8008/_synapse/admin/v1/register | jq -r .nonce)"
+ run: echo "::set-output nonce=$(curl http://synapse:8008/_synapse/admin/v1/register | jq -r .nonce)"
- name: Generate mac
id: generate_mac
run: python3 ./dockerfiles/synapse_generate_mac.py
env:
NONCE: ${{ steps.get_nonce.outputs.nonce }}
- name: Register
- run: 'curl -X POST http://localhost:8008/_synapse/admin/v1/register -d ''{"mac": "${MAC}", "nonce": "${NONCE}", "username": "fuzzer", "password": "Chu8chool0dooqueiwo0lohviegho6ieveuNg3Ohcio2aekaiw0ioF6waifo8eep"}'''
+ run: 'curl -X POST http://synapse:8008/_synapse/admin/v1/register -d ''{"mac": "${MAC}", "nonce": "${NONCE}", "username": "fuzzer", "password": "Chu8chool0dooqueiwo0lohviegho6ieveuNg3Ohcio2aekaiw0ioF6waifo8eep"}'''
env:
MAC: ${{ steps.generate_mac.outputs.hmac }}
NONCE: ${{ steps.get_nonce.outputs.nonce }}
- name: Run tests
run: cargo test
env:
+ MATRIX_SERVER: "http://synapse:8008"
MATRIX_USERNAME: "fuzzer"
MATRIX_PASSWORD: "Chu8chool0dooqueiwo0lohviegho6ieveuNg3Ohcio2aekaiw0ioF6waifo8eep"
diff --git a/dockerfiles/synapse_config.yaml b/dockerfiles/synapse_config.yaml
@@ -1,7 +1,7 @@
## Server ##
-server_name: "localhost"
-public_baseurl: "http://localhost:8008"
+server_name: "synapse"
+public_baseurl: "http://synapse:8008"
pid_file: /homeserver.pid
web_client: False
soft_file_limit: 0
@@ -40,8 +40,8 @@ listeners:
compress: false
## Files ##
-media_store_path: "/synapse/data/media"
-uploads_path: "/synapse/data/uploads"
+media_store_path: "/data/media"
+uploads_path: "/data/uploads"
## Registration ##
registration_shared_secret: "sahZae3yahjaequ8boh2cae5uo5eiciede2hoa9eew8mai1oy4iiChietheequ9U"
diff --git a/src/lib.rs b/src/lib.rs
@@ -30,6 +30,10 @@ pub fn client() -> &'static reqwest::blocking::Client {
#[no_coverage]
fn login() -> String {
+ let server = match env::var("MATRIX_SERVER") {
+ Ok(v) => v,
+ Err(e) => "http://localhost:8008".to_string(),
+ };
let username = match env::var("MATRIX_USERNAME") {
Ok(v) => v,
Err(e) => panic!("$MATRIX_USERNAME is not set ({})", e),
@@ -40,7 +44,7 @@ fn login() -> String {
};
let client = crate::client();
let res: LoginGet = client
- .get("http://localhost:8008/_matrix/client/v3/login")
+ .get(format!("{}/_matrix/client/v3/login", server))
.send()
.unwrap()
.json()
@@ -54,7 +58,7 @@ fn login() -> String {
map.insert("user", &username);
map.insert("password", &password);
let res: LoginPost = client
- .post("http://localhost:8008/_matrix/client/v3/login")
+ .post(format!("{}/_matrix/client/v3/login", server))
.json(&map)
.send()
.unwrap()
@@ -66,7 +70,7 @@ fn login() -> String {
#[cfg(all(test, not(fuzzing)))]
mod tests {
- use std::time::Instant;
+ use std::{env, time::Instant};
use reqwest::header::{HeaderValue, CONTENT_TYPE};
use serde_json::json;
@@ -76,9 +80,13 @@ mod tests {
#[test]
#[no_coverage]
fn connection_test() {
+ let server = match env::var("MATRIX_SERVER") {
+ Ok(v) => v,
+ Err(e) => "http://localhost:8008".to_string(),
+ };
let client = crate::client();
let resp = client
- .get("http://localhost:8008/_matrix/key/v2/server")
+ .get(format!("{}/_matrix/key/v2/server", server))
.send()
.unwrap();
assert!(resp.status().is_success());
@@ -97,8 +105,12 @@ mod tests {
};
let access_token = crate::access_token();
let client = crate::client();
+ let server = match env::var("MATRIX_SERVER") {
+ Ok(v) => v,
+ Err(e) => "http://localhost:8008".to_string(),
+ };
let resp = client
- .post("http://localhost:8008/_matrix/client/v3/createRoom")
+ .post(format!("{}/_matrix/client/v3/createRoom", server))
.header("Authorization", format!("Bearer {}", access_token))
.json(&content)
.send()
@@ -188,8 +200,12 @@ mod tests {
let access_token = crate::access_token();
let client = crate::client();
let start = Instant::now();
+ let server = match env::var("MATRIX_SERVER") {
+ Ok(v) => v,
+ Err(e) => "http://localhost:8008".to_string(),
+ };
let resp = client
- .post("http://localhost:8008/_matrix/client/v3/createRoom")
+ .post(format!("{}/_matrix/client/v3/createRoom", server))
.header("Authorization", format!("Bearer {}", access_token))
.json(&content)
.send()
@@ -211,8 +227,12 @@ mod tests {
let content = std::fs::read_to_string("./weird_ones/af84a60a1b7997b4.json").unwrap();
let access_token = crate::access_token();
let client = crate::client();
+ let server = match env::var("MATRIX_SERVER") {
+ Ok(v) => v,
+ Err(e) => "http://localhost:8008".to_string(),
+ };
let resp = client
- .post("http://localhost:8008/_matrix/client/v3/createRoom")
+ .post(format!("{}/_matrix/client/v3/createRoom", server))
.header("Authorization", format!("Bearer {}", access_token))
.header(CONTENT_TYPE, HeaderValue::from_static("application/json"))
.body(content)
@@ -276,8 +296,12 @@ mod tests {
}*/
let client = crate::client();
+ let server = match env::var("MATRIX_SERVER") {
+ Ok(v) => v,
+ Err(e) => "http://localhost:8008".to_string(),
+ };
let resp = client
- .post("http://localhost:8008/_matrix/client/v3/login")
+ .post(format!("{}/_matrix/client/v3/login", server))
.json(&json_data)
.send();
if let Ok(resp) = resp {
@@ -305,8 +329,12 @@ mod tests {
#[test]
fn fuzz_login() {
let client = crate::client();
+ let server = match env::var("MATRIX_SERVER") {
+ Ok(v) => v,
+ Err(e) => "http://localhost:8008".to_string(),
+ };
let resp = client
- .get("http://localhost:8008/_matrix/key/v2/server")
+ .get(format!("{}/_matrix/key/v2/server", server))
.send()
.unwrap();
if !resp.status().is_success() {
@@ -357,8 +385,12 @@ mod tests {
// TODO: Login once and reuse the access token
let access_token = crate::access_token();
let client = crate::client();
+ let server = match env::var("MATRIX_SERVER") {
+ Ok(v) => v,
+ Err(e) => "http://localhost:8008".to_string(),
+ };
let resp = client
- .post("http://localhost:8008/_matrix/client/v3/createRoom")
+ .post(format!("{}/_matrix/client/v3/createRoom", server))
.header("Authorization", format!("Bearer {}", access_token))
.json(&json_data)
.send();
@@ -392,8 +424,12 @@ mod tests {
#[test]
fn fuzz_create_room() {
let client = crate::client();
+ let server = match env::var("MATRIX_SERVER") {
+ Ok(v) => v,
+ Err(e) => "http://localhost:8008".to_string(),
+ };
let resp = client
- .get("http://localhost:8008/_matrix/key/v2/server")
+ .get(format!("{}/_matrix/key/v2/server", server))
.send()
.unwrap();
if !resp.status().is_success() {