Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
com.github.mikesafonov:smpp-server-mock-assertj
Advanced tools
This project helps to write integration test for applications uses SMPP connection.
smpp-server-mock
comes with:
MockSmppServer
MockSmppExtension
MockSmppBootstrapConfiguration
smpp-server-mock-core
consist of two main classes:
MockSmppServer
and
MockSmppServerHolder
.
MockSmppServer
represents smpp server which listening connections, received request, produce response and
keep requests in in-memory queue QueueSmppSessionHandler
.
Add JUnit 5
test dependencies:
Maven:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
Gradle:
dependencies{
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
}
Add extension dependency com.github.mikesafonov:smpp-server-mock-junit
:
Maven:
<dependency>
<groupId>com.github.mikesafonov</groupId>
<artifactId>smpp-server-mock-junit</artifactId>
<version>${version}</version>
<scope>test</scope>
</dependency>
Gradle:
dependencies{
testImplementation("com.github.mikesafonov:smpp-server-mock-junit:${version}")
}
Test example:
@ExtendWith(MockSmppExtension.class)
public class MyTest {
@SmppServer(systemId = "customSystemId", password = "password")
MockSmppServer mockSmppServer;
@Test
void shouldSendSms(){
// create some class to send SMS and connect to mock server, example:
MySmsSender sender = new MySmsSender("localhost", mockSmppServer.getPort(),
"customSystemId", "password");
sender.sendSms("message", "number");
List<SubmitSm> messages = mockSmppServer.getSubmitSmMessages();
SubmitSm message = messages.get(0);
assertEquals("number", message.getDestAddress().getAddress());
}
}
You may set clearAfterTest
to true
in SmppServer
if you want to clear all incoming requests after each test run.
By default
clearAfterTest
is false
.
com.github.mikesafonov:smpp-server-mock-assertj
helps to write more intuitive assertions for SMPP objects.
To start using AssertJ assertions you need to:
assertj-core
dependencycom.github.mikesafonov:smpp-server-mock-assertj
dependencyMaven:
<dependency>
<groupId>com.github.mikesafonov</groupId>
<artifactId>smpp-server-mock-assertj</artifactId>
<version>${version}</version>
<scope>test</scope>
</dependency>
Gradle:
dependencies{
testImplementation("com.github.mikesafonov:smpp-server-mock-assertj:${version}")
}
Assertions for MockSmppServer:
SmppAssertions.assertThat(mockSmppServer)
.hasPort(2000)
.hasName("myserver")
.hasSystemId("systemId")
.hasSingleMessage() // assert for single SubmitSm
.hasSingleCancelMessage() // assert for single CancelSm
.messages()// assert for list of SubmitSm
.cancelMessages()// assert for list of CancelSm
.requests();//assert for list of any request
Assertions for SubmitSm:
SmppAssertions.assertThat(mockSmppServer)
.hasSingleMessage()
.hasDest("number")
.hasText("message")
.hasEsmClass(esmClass)
.hasDeliveryReport()
.doesNotHaveDeliveryReport()
.hasSource("someSource");
or
SmppAssertions.assertThat(submitSm)
.hasDest("number")
.hasText("message")
.hasEsmClass(esmClass)
.hasDeliveryReport()
.doesNotHaveDeliveryReport()
.hasSource("someSource");
Assertions for CancelSm:
SmppAssertions.assertThat(mockSmppServer)
.hasSingleCancelMessage()
.hasDest("number")
.hasId("messageId")
.hasSource("someSource");
or
SmppAssertions.assertThat(cancelSm)
.hasDest("number")
.hasId("messageId")
.hasSource("someSource");
Assertions for list of SubmitSm:
SmppAssertions.assertThat(mockSmppServer)
.messages()
.containsDest(destAddress)
.containsText(text)
.containsEsmClass(esmClass)
.containsSource(sourceAddress);
or
SmppAssertions.assertThatSubmit(listOfSubmitSm)
.containsDest(destAddress)
.containsText(text)
.containsEsmClass(esmClass)
.containsSource(sourceAddress);
Assertions for list of CancelSm:
SmppAssertions.assertThat(mockSmppServer)
.cancelMessages()
.containsDest(destAddress)
.containsId(messageId)
.containsSource(sourceAddress);
or
SmppAssertions.assertThat(listOfCancelSm)
.containsDest(destAddress)
.containsId(messageId)
.containsSource(sourceAddress);
Assertions for MockSmppServerHolder:
SmppAssertions.assertThat(holder)
.allStarted() // verify that all MockSmppServer started
.serverByName("first); // find MockSmppServer by name and return assertions
Spring boot starter are used to bootstrap MockSmppServer
servers using spring cloud bootstrap phase.
Add spring-cloud
and spring-boot-starter-test
test dependencies:
Maven:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
<version>cloud-version</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>version</version>
<scope>test</scope>
</dependency>
Gradle:
dependencies{
testImplementation("org.springframework.cloud:spring-cloud-starter:${cloud-version}")
testImplementation("org.springframework.boot:spring-boot-starter-test:${version}")
}
Add extension dependency com.github.mikesafonov:smpp-server-mock-spring-boot
:
Maven:
<dependency>
<groupId>com.github.mikesafonov</groupId>
<artifactId>smpp-server-mock-spring-boot</artifactId>
<version>${version}</version>
<scope>test</scope>
</dependency>
Gradle:
dependencies{
testImplementation("com.github.mikesafonov:smpp-server-mock-spring-boot:${version}")
}
The starter consumes properties:
smpp.mocks.<server name>.port
(optional, default random)
smpp.mocks.<server name>.password
smpp.mocks.<server name>.system-id
The starter produces properties:
smpp.mocks.<server name>.host
(always localhost
)
smpp.mocks.<server name>.port
smpp.mocks.<server name>.password
smpp.mocks.<server name>.system-id
bootstrap.properties:
smpp.mocks.one.password=test
smpp.mocks.one.system-id=user
application.properties:
# some properties to smpp connection in your app
my.smpp.connection.host=${smpp.mocks.one.host}
my.smpp.connection.port=${smpp.mocks.one.port}
my.smpp.connection.password=${smpp.mocks.one.password}
my.smpp.connection.systemId=${smpp.mocks.one.system-id}
test:
@SpringBootTest
class SingleServer extends BaseSmppTest {
@Autowired
protected MockSmppServerHolder holder;
@Test
void shouldRunExpectedSmppServer() {
// test logic
List<PduRequest> requests =
holder.getByName("one").get().getRequests();
// verify smpp requests
}
}
You can build application using following command:
./gradlew clean build -x signArchives
JDK >= 1.8
You can run unit tests using following command:
./gradlew test
You can run mutation tests using following command:
./grdlew pitest
You will be able to find pitest report in build/reports/pitest/
folder.
Feel free to contribute. New feature proposals and bug fixes should be submitted as GitHub pull requests. Fork the repository on GitHub, prepare your change on your forked copy, and submit a pull request.
IMPORTANT!
Before contributing please read about Conventional Commits / Conventional Commits RU
FAQs
AssertJ asserts for smpp-server-mock
We found that com.github.mikesafonov:smpp-server-mock-assertj demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.