This repository has been archived by the owner on Apr 12, 2023. It is now read-only.
感染性のある期間を有症状の場合は症状発生から10日、無症状の場合は検査日から7日とする #841
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fd9cd38
WIP
keiji ef0b775
Apply app
keiji 9af37a5
Fix test.
keiji e285843
Update DeviceVerification seed.
keiji db0def1
Refactoring.
keiji ec48c13
Fix test.
keiji 0bbc04b
Refactoring.
keiji f6399a0
Change DeviceVerification for V3DiagnosisApi.
keiji bfd3466
Style nitpick.
keiji b8d7120
Add license.
keiji 3274d99
Fix typo OnSet to Onset.
keiji 8f5972d
Merge branch 'develop' of github.com:cocoa-mhlw/cocoa into feature/sw…
keiji 6784b8d
Add parameters to local.settings.json.example
keiji File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
using System; | ||
using Covid19Radar.Api.Extensions; | ||
using System.Text; | ||
using Covid19Radar.Api.Models; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
@@ -14,11 +13,13 @@ namespace Covid19Radar.Api.Tests.Models | |
[TestCategory("Models")] | ||
public class V3DiagnosisSubmissionParameterTest | ||
{ | ||
private const string EXPECTED_CLEAR_TEXT_V3 = "2021-12-19T19:02:00.000+09:00|jp.go.mhlw.cocoa.unit_test|S2V5RGF0YTE=.10000.140.1,S2V5RGF0YTI=.20000.141.1,S2V5RGF0YTM=.30000.142.1,S2V5RGF0YTQ=.40000.143.1,S2V5RGF0YTU=.50000.70.1|440,441|VerificationPayload THIS STRING IS MEANINGLESS"; | ||
private const string EXPECTED_TRANSACTION_ID_SEED_V3 = "2021-12-19T19:02:00.000+09:00jp.go.mhlw.cocoa.unit_testS2V5RGF0YTE=.10000.140.1,S2V5RGF0YTI=.20000.141.1,S2V5RGF0YTM=.30000.142.1,S2V5RGF0YTQ=.40000.143.1,S2V5RGF0YTU=.50000.70.1440,441"; | ||
private const string EXPECTED_CLEAR_TEXT_V3_HASSYMPTOM = "jp.go.mhlw.cocoa.unit_test|2021-12-19T19:02:00.000+09:00|HasSymptom|S2V5RGF0YTE=.10000.140.1,S2V5RGF0YTI=.20000.141.1,S2V5RGF0YTM=.30000.142.1,S2V5RGF0YTQ=.40000.143.1,S2V5RGF0YTU=.50000.70.1|440,441|VerificationPayload THIS STRING IS MEANINGLESS"; | ||
private const string EXPECTED_TRANSACTION_ID_SEED_V3_HASSYMPTOM = "jp.go.mhlw.cocoa.unit_test2021-12-19T19:02:00.000+09:00HasSymptomS2V5RGF0YTE=.10000.140.1,S2V5RGF0YTI=.20000.141.1,S2V5RGF0YTM=.30000.142.1,S2V5RGF0YTQ=.40000.143.1,S2V5RGF0YTU=.50000.70.1440,441"; | ||
private const string EXPECTED_CLEAR_TEXT_V3_NOSYMPTOM = "jp.go.mhlw.cocoa.unit_test|2021-12-19T19:02:00.000+09:00|NoSymptom|S2V5RGF0YTE=.10000.140.1,S2V5RGF0YTI=.20000.141.1,S2V5RGF0YTM=.30000.142.1,S2V5RGF0YTQ=.40000.143.1,S2V5RGF0YTU=.50000.70.1|440,441|VerificationPayload THIS STRING IS MEANINGLESS"; | ||
private const string EXPECTED_TRANSACTION_ID_SEED_V3_NOSYMPTOM = "jp.go.mhlw.cocoa.unit_test2021-12-19T19:02:00.000+09:00NoSymptomS2V5RGF0YTE=.10000.140.1,S2V5RGF0YTI=.20000.141.1,S2V5RGF0YTM=.30000.142.1,S2V5RGF0YTQ=.40000.143.1,S2V5RGF0YTU=.50000.70.1440,441"; | ||
|
||
private const string EXPECTED_CLEAR_TEXT_V3_NO_KEY = "2021-12-19T19:02:00.000+09:00|jp.go.mhlw.cocoa.unit_test||440,441|VerificationPayload THIS STRING IS MEANINGLESS"; | ||
private const string EXPECTED_TRANSACTION_ID_SEED_V3_NO_KEY = "2021-12-19T19:02:00.000+09:00jp.go.mhlw.cocoa.unit_test440,441"; | ||
private const string EXPECTED_CLEAR_TEXT_V3_NO_KEY = "jp.go.mhlw.cocoa.unit_test|2021-12-19T19:02:00.000+09:00|HasSymptom||440,441|VerificationPayload THIS STRING IS MEANINGLESS"; | ||
private const string EXPECTED_TRANSACTION_ID_SEED_V3_NO_KEY = "jp.go.mhlw.cocoa.unit_test2021-12-19T19:02:00.000+09:00HasSymptom440,441"; | ||
Comment on lines
-17
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 症状の有無でDeviceVerificaitonのClearTextの内容が変わる。 サーバー側のテスト調整。 テストデータは |
||
|
||
[TestMethod] | ||
public void CreateMethod() | ||
|
@@ -36,37 +37,6 @@ public void PropertiesTest() | |
Helper.ModelTestHelper.PropetiesTest(model); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("KEYDATA", 0, 0, 0, true)] | ||
[DataRow("KEYDATA", 145, 0, 0, false)] | ||
[DataRow("KEYDATA", 144, -15, 0, false)] | ||
[DataRow("KEYDATA", 144, -14, 0, true)] | ||
[DataRow("KEYDATA", 144, -6, 0, true)] | ||
[DataRow("KEYDATA", 144, -5, 0, true)] | ||
[DataRow("KEYDATA", 144, -4, 0, true)] | ||
[DataRow("KEYDATA", 144, -3, 0, true)] | ||
[DataRow("KEYDATA", 144, -2, 0, true)] | ||
[DataRow("KEYDATA", 144, -1, 0, true)] | ||
[DataRow("KEYDATA", 144, 0, 0, true)] | ||
[DataRow("KEYDATA", 144, 0, -14, true)] | ||
[DataRow("KEYDATA", 144, 0, 14, true)] | ||
[DataRow("KEYDATA", 144, 0, -15, false)] | ||
[DataRow("KEYDATA", 144, 0, 15, false)] | ||
[DataRow("KEYDATA", 144, 1, 0, false)] | ||
public void KeyValidationTest(string keyData, int rollingPeriod, int rollingStartNummberDayOffset, int daysSinceOnsetOfSymptoms, bool isValid) | ||
{ | ||
var dateTime = DateTime.UtcNow.Date; | ||
|
||
var key = CreateDiagnosisKey( | ||
keyData, | ||
(int)dateTime.AddDays(rollingStartNummberDayOffset).ToRollingStartNumber(), | ||
rollingPeriod, | ||
1, | ||
daysSinceOnsetOfSymptoms | ||
); | ||
Assert.AreEqual(isValid, key.IsValid()); | ||
} | ||
Comment on lines
-39
to
-68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. V3DiagnosisSubmissionParameter.Keyの
|
||
|
||
private static V3DiagnosisSubmissionParameter.Key CreateDiagnosisKey( | ||
string keyData, | ||
int rollingStartNumber, | ||
|
@@ -89,7 +59,60 @@ int daysSinceOnsetOfSymptoms | |
} | ||
|
||
[TestMethod] | ||
public void DeviceVerificationTest() | ||
public void DeviceVerificationTest_HasSymptom() | ||
{ | ||
var platform = "Android"; | ||
var dummyDiagnosisKeyDataList = new[] { | ||
CreateDiagnosisKey("KeyData1", 10000, 140, 1, -1), | ||
CreateDiagnosisKey("KeyData2", 20000, 141, 1, 0), | ||
CreateDiagnosisKey("KeyData3", 30000, 142, 1, 1), | ||
CreateDiagnosisKey("KeyData4", 40000, 143, 1, 2), | ||
CreateDiagnosisKey("KeyData5", 50000, 70, 1, 3), | ||
}; | ||
|
||
var dummyRegions = new string[] | ||
{ | ||
"440", | ||
"441", | ||
}; | ||
var dummySymptomOnsetDate = "2021-12-19T19:02:00.000+09:00"; | ||
|
||
var dummyDeviceVerificationPayload = "DeviceVerificationPayload THIS STRING IS MEANINGLESS"; | ||
var dummyAppPackageName = "jp.go.mhlw.cocoa.unit_test"; | ||
var dummyVerificationPayload = "VerificationPayload THIS STRING IS MEANINGLESS"; | ||
|
||
// This value will not affect any result. | ||
var dummyPadding = new Random().Next().ToString(); | ||
|
||
// preparation | ||
var model = new V3DiagnosisSubmissionParameter() | ||
{ | ||
HasSymptom = true, | ||
Platform = platform, | ||
Regions = dummyRegions, | ||
OnsetOfSymptomOrTestDate = dummySymptomOnsetDate, | ||
Keys = dummyDiagnosisKeyDataList, | ||
DeviceVerificationPayload = dummyDeviceVerificationPayload, | ||
AppPackageName = dummyAppPackageName, | ||
VerificationPayload = dummyVerificationPayload, | ||
Padding = dummyPadding, | ||
}; | ||
|
||
Assert.AreEqual(dummyDeviceVerificationPayload, model.JwsPayload); | ||
Assert.AreEqual( | ||
EXPECTED_CLEAR_TEXT_V3_HASSYMPTOM, | ||
model.ClearText | ||
); | ||
|
||
Assert.AreEqual(dummyDeviceVerificationPayload, model.DeviceToken); | ||
Assert.AreEqual( | ||
EXPECTED_TRANSACTION_ID_SEED_V3_HASSYMPTOM, | ||
model.TransactionIdSeed | ||
); | ||
} | ||
|
||
[TestMethod] | ||
public void DeviceVerificationTest_NoSymptom() | ||
{ | ||
var platform = "Android"; | ||
var dummyDiagnosisKeyDataList = new[] { | ||
|
@@ -117,9 +140,10 @@ public void DeviceVerificationTest() | |
// preparation | ||
var model = new V3DiagnosisSubmissionParameter() | ||
{ | ||
HasSymptom = false, | ||
Platform = platform, | ||
Regions = dummyRegions, | ||
SymptomOnsetDate = dummySymptomOnsetDate, | ||
OnsetOfSymptomOrTestDate = dummySymptomOnsetDate, | ||
Keys = dummyDiagnosisKeyDataList, | ||
DeviceVerificationPayload = dummyDeviceVerificationPayload, | ||
AppPackageName = dummyAppPackageName, | ||
|
@@ -129,13 +153,13 @@ public void DeviceVerificationTest() | |
|
||
Assert.AreEqual(dummyDeviceVerificationPayload, model.JwsPayload); | ||
Assert.AreEqual( | ||
EXPECTED_CLEAR_TEXT_V3, | ||
EXPECTED_CLEAR_TEXT_V3_NOSYMPTOM, | ||
model.ClearText | ||
); | ||
|
||
Assert.AreEqual(dummyDeviceVerificationPayload, model.DeviceToken); | ||
Assert.AreEqual( | ||
EXPECTED_TRANSACTION_ID_SEED_V3, | ||
EXPECTED_TRANSACTION_ID_SEED_V3_NOSYMPTOM, | ||
model.TransactionIdSeed | ||
); | ||
} | ||
|
@@ -164,9 +188,10 @@ public void DeviceVerificationTest_NoKey() | |
// preparation | ||
var model = new V3DiagnosisSubmissionParameter() | ||
{ | ||
HasSymptom = true, | ||
Platform = platform, | ||
Regions = dummyRegions, | ||
SymptomOnsetDate = dummySymptomOnsetDate, | ||
OnsetOfSymptomOrTestDate = dummySymptomOnsetDate, | ||
Keys = dummyDiagnosisKeyDataList, | ||
DeviceVerificationPayload = dummyDeviceVerificationPayload, | ||
AppPackageName = dummyAppPackageName, | ||
|
@@ -210,9 +235,10 @@ public void DeviceVerificationTestKeysNull() | |
// preparation | ||
var model = new V3DiagnosisSubmissionParameter() | ||
{ | ||
HasSymptom = true, | ||
Platform = platform, | ||
Regions = dummyRegions, | ||
SymptomOnsetDate = dummySymptomOnsetDate, | ||
OnsetOfSymptomOrTestDate = dummySymptomOnsetDate, | ||
Keys = dummyDiagnosisKeyDataList, | ||
DeviceVerificationPayload = dummyDeviceVerificationPayload, | ||
AppPackageName = dummyAppPackageName, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
症状の有無でDeviceVerificaitonのClearTextの内容が変わる。
アプリ側のテスト調整。
テストデータは
src/Covid19Radar.Api.Tests/Models/V3DiagnosisSubmissionParameterTest
のものと一致する。