-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
108 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
import io.supertokens.ProcessState; | ||
import io.supertokens.ProcessState.PROCESS_STATE; | ||
import io.supertokens.cronjobs.telemetry.Telemetry; | ||
import io.supertokens.dashboard.Dashboard; | ||
import io.supertokens.httpRequest.HttpRequestMocking; | ||
import io.supertokens.test.TestingProcessManager.TestingProcess; | ||
import io.supertokens.version.Version; | ||
|
@@ -111,6 +112,14 @@ public void testThatTelemetryWorks() throws Exception { | |
String[] args = { "../" }; | ||
|
||
TestingProcess process = TestingProcessManager.start(args, false); | ||
process.startProcess(); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED)); | ||
|
||
Dashboard.signUpDashboardUser(process.getProcess(), "[email protected]", "password123"); | ||
|
||
// Restarting the process to send telemetry again | ||
process.kill(); | ||
process = TestingProcessManager.start(args, false); | ||
|
||
ByteArrayOutputStream output = new ByteArrayOutputStream(); | ||
final HttpURLConnection mockCon = mock(HttpURLConnection.class); | ||
|
@@ -149,10 +158,18 @@ protected URLConnection openConnection(URL u) { | |
assertNotNull(process.checkOrWaitForEvent(PROCESS_STATE.SENT_TELEMETRY)); | ||
|
||
JsonObject telemetryData = new JsonParser().parse(output.toString()).getAsJsonObject(); | ||
assertEquals(7, telemetryData.entrySet().size()); | ||
|
||
assertTrue(telemetryData.has("telemetryId")); | ||
assertEquals(telemetryData.get("superTokensVersion").getAsString(), | ||
Version.getVersion(process.getProcess()).getCoreVersion()); | ||
assertEquals(telemetryData.get("appId").getAsString(), "public"); | ||
assertEquals(telemetryData.get("connectionUriDomain").getAsString(), ""); | ||
assertTrue(telemetryData.has("maus")); | ||
assertTrue(telemetryData.has("dashboardUserEmails")); | ||
assertEquals(1, telemetryData.get("dashboardUserEmails").getAsJsonArray().size()); | ||
assertEquals("[email protected]", telemetryData.get("dashboardUserEmails").getAsJsonArray().get(0).getAsString()); | ||
assertEquals(30, telemetryData.get("maus").getAsJsonArray().size()); | ||
|
||
process.kill(); | ||
assertNotNull(process.checkOrWaitForEvent(PROCESS_STATE.STOPPED)); | ||
|