Skip to content

Commit

Permalink
✅ Add more tests #97
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Fihlon <[email protected]>
  • Loading branch information
McPringle committed Apr 19, 2024
1 parent b46bf0d commit 2bd8ab7
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/test/java/swiss/fihlon/apus/configuration/AdminConfigTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Apus - A social wall for conferences with additional features.
* Copyright (C) Marcus Fihlon and the individual contributors to Apus.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swiss.fihlon.apus.configuration;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import swiss.fihlon.apus.util.PasswordUtil;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@SpringBootTest
class AdminConfigTest {

@Autowired
private Configuration configuration;

@Test
void testAdminConfig() {
final var adminConfig = configuration.getAdmin();
assertNotNull(adminConfig);
assertFalse(adminConfig.password().isBlank());
assertTrue(PasswordUtil.matches("12345", adminConfig.password()));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Apus - A social wall for conferences with additional features.
* Copyright (C) Marcus Fihlon and the individual contributors to Apus.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swiss.fihlon.apus.configuration;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@SpringBootTest
class ConfigurationTest {

@Autowired
private Configuration configuration;

@Test
void testConfiguration() {
assertNotNull(configuration);
assertFalse(configuration.getVersion().isBlank());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Apus - A social wall for conferences with additional features.
* Copyright (C) Marcus Fihlon and the individual contributors to Apus.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swiss.fihlon.apus.configuration;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@SpringBootTest
class FilterConfigTest {

@Autowired
private Configuration configuration;

@Test
void testFilterConfig() {
final var filterConfig = configuration.getFilter();
assertNotNull(filterConfig);
assertEquals(500, filterConfig.length());
assertFalse(filterConfig.replies());
assertTrue(filterConfig.sensitive());
assertIterableEquals(List.of("foo", "bar", "foobar", "barfoo"), filterConfig.words());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Apus - A social wall for conferences with additional features.
* Copyright (C) Marcus Fihlon and the individual contributors to Apus.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swiss.fihlon.apus.plugin.agenda.doag;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import swiss.fihlon.apus.configuration.Configuration;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@SpringBootTest
class DoagConfigTest {

@Autowired
private Configuration configuration;

@Test
void testDoagConfig() {
final var doagConfig = configuration.getDoag();
assertNotNull(doagConfig);
assertEquals(-1, doagConfig.eventId());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Apus - A social wall for conferences with additional features.
* Copyright (C) Marcus Fihlon and the individual contributors to Apus.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swiss.fihlon.apus.plugin.social.mastodon;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import swiss.fihlon.apus.configuration.Configuration;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@SpringBootTest
class MastodonConfigTest {

@Autowired
private Configuration configuration;

@Test
void testMastodonConfig() {
final var mastodonConfig = configuration.getMastodon();
assertNotNull(mastodonConfig);
assertEquals("mastodon.social", mastodonConfig.instance());
assertEquals("java", mastodonConfig.hashtag());
assertTrue(mastodonConfig.imagesEnabled());
assertEquals(1, mastodonConfig.imageLimit());
}

}
11 changes: 11 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apus.version[email protected]@
apus.admin.password=$2a$10$nybQbl/iY8SRJkfHJVncS.L5.OC3KJ6VRBYVAID7qnUqwylmn/BtK
apus.filter.length=500
apus.filter.replies=false
apus.filter.sensitive=true
apus.filter.words=foo, bar, foobar, barfoo
apus.doag.eventId=-1
apus.mastodon.instance=mastodon.social
apus.mastodon.hashtag=java
apus.mastodon.imagesEnabled=true
apus.mastodon.imageLimit=1

0 comments on commit 2bd8ab7

Please sign in to comment.