Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open API Update - Sync with Open API PR 249 #420

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import com.okta.sdk.resource.log.LogSecurityContext
import com.okta.sdk.resource.log.LogSeverity
import com.okta.sdk.resource.log.LogTransaction
import com.okta.sdk.resource.log.LogUserAgent
import org.mockito.ArgumentCaptor
import org.mockito.Mockito
import static org.mockito.Mockito.verify

import org.testng.annotations.BeforeMethod
import org.testng.annotations.Test

import java.time.Instant
Expand All @@ -42,14 +46,18 @@ import static org.hamcrest.Matchers.*
import static org.hamcrest.MatcherAssert.*

class LogsTest {
MockClient client

@BeforeMethod
void setup() {
// mock the response objects in the client
client = new MockClient()
.withMockResponse(Mockito.any(Request), '/stubs/logs.json')
}

@Test
void testGetLogs() {

// Mock the response objects in the client
MockClient client = new MockClient()
.withMockResponse(Mockito.any(Request), '/stubs/logs.json')

// get the list of logs
List<LogEvent> logs = client.getLogs().stream().collect(Collectors.toList())
assertThat logs, hasSize(100)
Expand Down Expand Up @@ -145,4 +153,50 @@ class LogsTest {
assertThat log.getRequest().getIpChain().get(0).getGeographicalContext().getGeolocation().lat, equalTo(43.3091d)
assertThat log.getRequest().getIpChain().get(0).getGeographicalContext().getGeolocation().lon, equalTo(-71.6861d)
}
}

@Test
void testGetLogsBetweenDates() {

Date sinceDate = Date.from(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse("2017-11-30T21:15:16.838Z")))
Date untilDate = Date.from(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse("2017-11-30T21:16:00.081Z")))

// get log events between dates
List<LogEvent> logs = client.getLogs(sinceDate, untilDate, null, null, null).stream().collect(Collectors.toList())
logs.forEach { assertThat it, instanceOf(LogEvent) }

ArgumentCaptor<Request> argument = ArgumentCaptor.forClass(Request.class)
verify(client.mockRequestExecutor).executeRequest(argument.capture())
assertThat argument.getValue().queryString.since, instanceOf(String)
arvindkrishnakumar-okta marked this conversation as resolved.
Show resolved Hide resolved
assertThat argument.getValue().queryString.until, instanceOf(String)
}

@Test
void testGetLogsSinceDate() {

Date sinceDate = Date.from(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse("2017-11-30T21:15:16.838Z")))

// get log events since given date
List<LogEvent> logs = client.getLogs(sinceDate, null, null, null, null).stream().collect(Collectors.toList())
assertThat logs, hasSize(100)
logs.forEach { assertThat it, instanceOf(LogEvent) }

ArgumentCaptor<Request> argument = ArgumentCaptor.forClass(Request.class)
verify(client.mockRequestExecutor).executeRequest(argument.capture())
assertThat argument.getValue().queryString.since, instanceOf(String)
}

@Test
void testGetLogsUntilDate() {

Date untilDate = Date.from(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse("2017-11-30T21:16:00.081Z")))

// get log events until given date
List<LogEvent> logs = client.getLogs(null, untilDate, null, null, null).stream().collect(Collectors.toList())
assertThat logs, hasSize(100)
logs.forEach { assertThat it, instanceOf(LogEvent) }

ArgumentCaptor<Request> argument = ArgumentCaptor.forClass(Request.class)
verify(client.mockRequestExecutor).executeRequest(argument.capture())
assertThat argument.getValue().queryString.until, instanceOf(String)
}
}
6 changes: 4 additions & 2 deletions src/swagger/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3795,11 +3795,13 @@ paths:
operationId: getLogs
parameters:
- in: query
name: until
name: since
type: string
format: date-time
- in: query
name: since
name: until
type: string
format: date-time
- in: query
name: filter
type: string
Expand Down