Skip to content

Commit

Permalink
Added more Integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DAQEM committed Nov 6, 2023
1 parent b075635 commit 081efe7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ public SNMPDiscoverIntegrationTests(WebApplicationFactory<SNMPPollingProgram> fa
}

[Theory]
[InlineData("/Discover/Details")]
public async Task Get_EndpointsReturnSuccessAndCorrectContentType(string url)
[InlineData("/Discover/Details", "{\"ipAddress\":\"127.0.0.1\",\"port\":161,\"community\":\"public\",\"name\":\"snmpd-test\",\"location\":\"SNMPD Test\",\"contact\":\"Root <root@snmpd.test>\"}")]
[InlineData("/Discover/Device", "{\"ipAddress\":\"127.0.0.1\",\"name\":\"snmpd-test\",\"location\":\"SNMPD Test\",\"contact\":\"Root <root@snmpd.test>\",\"deviceConnection\":{\"port\":161,\"community\":\"public\",\"authPassword\":\"\",\"privacyPassword\":\"\",\"authProtocol\":\"SHA256\",\"privacyProtocol\":\"AES\",\"contextName\":\"\",\"snmpVersion\":1},\"disks\":[],\"cpus\":[],\"memory\":[],\"interfaces\":[]}")]
[InlineData("/Discover/Disks", "[]")]
[InlineData("/Discover/Memory", "[]")]
[InlineData("/Discover/Cpus", "[]")]
[InlineData("/Discover/Interfaces", "[]")]
public async Task Get_EndpointsReturnSuccessAndCorrectContentType(string url, string expectedJsonResponse)
{
// Arrange
HttpClient client = _factory.CreateClient();
Expand All @@ -33,10 +38,10 @@ public async Task Get_EndpointsReturnSuccessAndCorrectContentType(string url)
community = "public"
});

_testOutputHelper.WriteLine(await response.Content.ReadAsStringAsync());
// Assert
_testOutputHelper.WriteLine("Status code: {0}", response.StatusCode);
_testOutputHelper.WriteLine("Response: {0}", await response.Content.ReadAsStringAsync());
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType?.ToString());
Assert.Equal(expectedJsonResponse, await response.Content.ReadAsStringAsync());
}
}
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ services:
netmon-snmp-test-agent:
build: Tests/SNMPTestAgent
container_name: netmon-snmp-test-agent
hostname: snmpd-test
ports:
- "161:161/udp"
networks:
Expand Down

0 comments on commit 081efe7

Please sign in to comment.