感染性のある期間を有症状の場合は症状発生から10日、無症状の場合は検査日から7日とする #841
Conversation
string hasSymptom = submission.HasSymptom ? "HasSymptom" : "NoSymptom"; | ||
return string.Join("|", submission.AppPackageName, submission.OnSetOfSymptomOrTestDate, hasSymptom, GetKeyString(submission.Keys), GetRegionString(submission.Regions), submission.VerificationPayload); |
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.
症状の有無(HasSymptom)をDeviceVerificationのNonceのseedに含める。
[JsonProperty("symptomOnsetDate")] | ||
public string SymptomOnsetDate { get; set; } | ||
[JsonProperty("hasSymptom")] | ||
public bool HasSymptom { get; set; } | ||
|
||
[JsonProperty("onSetOfSymptomOrTestDate")] | ||
public string OnSetOfSymptomOrTestDate { get; set; } |
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.
SymptomOnsetDateをOnSetOfSymptomOrTestDate
にリネーム。
症状の有無を hasSymptom
で送る。
サーバー側( src/Covid19Radar.Api/Models/V3DiagnosisSubmissionParameter )と合わせる。
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_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"; |
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
のものと一致する。
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"; |
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の内容が変わる。
サーバー側のテスト調整。
テストデータは Covid19Radar/Tests/Covid19Radar.UnitTests/Common/DeviceVerifierUtilsTests
のものと一致する。
[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()); | ||
} |
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.
V3DiagnosisSubmissionParameter.KeyのIsValid
は廃止。
TemporaryExposureKeyValidationService
として実装する。
Assert.AreEqual(-7, resultParameter.Keys[0].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-6, resultParameter.Keys[1].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-5, resultParameter.Keys[2].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-4, resultParameter.Keys[3].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-3, resultParameter.Keys[4].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-2, resultParameter.Keys[5].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-1, resultParameter.Keys[6].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(0, resultParameter.Keys[7].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(1, resultParameter.Keys[8].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(2, resultParameter.Keys[9].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(3, resultParameter.Keys[10].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(4, resultParameter.Keys[11].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(5, resultParameter.Keys[12].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(6, resultParameter.Keys[13].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(7, resultParameter.Keys[14].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-8, resultParameter.Keys[0].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-7, resultParameter.Keys[1].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-6, resultParameter.Keys[2].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-5, resultParameter.Keys[3].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-4, resultParameter.Keys[4].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-3, resultParameter.Keys[5].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-2, resultParameter.Keys[6].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(-1, resultParameter.Keys[7].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(0, resultParameter.Keys[8].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(1, resultParameter.Keys[9].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(2, resultParameter.Keys[10].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(3, resultParameter.Keys[11].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(4, resultParameter.Keys[12].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(5, resultParameter.Keys[13].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(6, resultParameter.Keys[14].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(7, resultParameter.Keys[15].DaysSinceOnsetOfSymptoms); | ||
Assert.AreEqual(8, resultParameter.Keys[16].DaysSinceOnsetOfSymptoms); |
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.
KeyがValidかどうかのテストは src/Covid19Radar.Api.Tests/Services/TemporaryExposureKeyValidationServiceTest
が担当するので、このテストでフィルタリングについて考慮する必要はない。
public static int InfectiousFilterDaysSinceOnsetOfSymptomsFrom(this IConfiguration config) | ||
{ | ||
if (int.TryParse(config["InfectiousFilterDaysSinceOnsetOfSymptomsFrom"], out int result)) | ||
{ | ||
return result; | ||
} | ||
return Constants.MIN_DAYS_SINCE_ONSET_OF_SYMPTOMS; | ||
} | ||
public static int InfectiousFilterDaysSinceOnsetOfSymptomsTo(this IConfiguration config) | ||
{ | ||
if (int.TryParse(config["InfectiousFilterDaysSinceOnsetOfSymptomsTo"], out int result)) | ||
{ | ||
return result; | ||
} | ||
return Constants.MAX_DAYS_SINCE_ONSET_OF_SYMPTOMS; | ||
} | ||
public static int InfectiousFilterDaysSinceTestFrom(this IConfiguration config) | ||
{ | ||
if (int.TryParse(config["InfectiousFilterDaysSinceTestFrom"], out int result)) | ||
{ | ||
return result; | ||
} | ||
return Constants.MIN_DAYS_SINCE_ONSET_OF_SYMPTOMS; | ||
} | ||
public static int InfectiousFilterDaysSinceTestTo(this IConfiguration config) | ||
{ | ||
if (int.TryParse(config["InfectiousFilterDaysSinceTestTo"], out int result)) | ||
{ | ||
return result; | ||
} | ||
return Constants.MAX_DAYS_SINCE_ONSET_OF_SYMPTOMS; | ||
} |
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.
Azure FunctionsのConfigurationに設定する値。
- InfectiousFilterDaysSinceOnsetOfSymptomsFrom
- InfectiousFilterDaysSinceOnsetOfSymptomsTo
- InfectiousFilterDaysSinceTestFrom
- InfectiousFilterDaysSinceTestTo
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.
local.settings.json.exampleこちらに追加していただくと追加があることが把握しやすいです。
ローカルで動かす際もこのファイルをベースにlocal.settings.jsonを作成しますので、その意味でも追加していただけると助かります。
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.
6784b8d で対応しました!
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.
確認しました。ありがとうございます。
[JsonProperty("onSetOfSymptomOrTestDate")] | ||
public string OnSetOfSymptomOrTestDate { get; set; } |
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.
症状の有無(hasSymptom
)と症状が現れた日・または診断日(onSetOfSymptomOrTestDate
)。
Covid19Radar/Covid19Radar/Model/DiagnosisSubmissionParameter
と合わせる。
/// <summary> | ||
/// Validation | ||
/// </summary> | ||
/// <returns>true if valid</returns> | ||
public bool IsValid() | ||
{ | ||
if (string.IsNullOrWhiteSpace(KeyData)) return false; | ||
if (RollingPeriod > Constants.ActiveRollingPeriod) return false; | ||
|
||
var dateTime = DateTime.UtcNow.Date; | ||
var todayRollingStartNumber = dateTime.ToRollingStartNumber(); | ||
|
||
var oldestRollingStartNumber = dateTime.AddDays(Constants.OutOfDateDays).ToRollingStartNumber(); | ||
if (RollingStartNumber < oldestRollingStartNumber || RollingStartNumber > todayRollingStartNumber) | ||
{ | ||
return false; | ||
} | ||
|
||
if (DaysSinceOnsetOfSymptoms < MIN_DAYS_SINCE_ONSET_OF_SYMPTOMS | ||
|| DaysSinceOnsetOfSymptoms > MAX_DAYS_SINCE_ONSET_OF_SYMPTOMS) | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} |
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.
廃止してTemporaryExposureKeyValidationService
に任せる。
V1, V2は移動させない。DeviceVerificationと方針が異なるのはAttestations Apiなどは外部環境の変化(Attestation APIのアップグレードや仕様変更)があるのにたいして、この点についてはコントローラブルなので各バージョンの処理を別に定義しても差し支えないと考えたため。
ぜんぶのバージョンのValidationをここに集めるのが一番きれいなので、時間があればやりたい。
if (hasSymptom) | ||
{ | ||
_logger.LogDebug("hasSymptom"); | ||
|
||
if (_infectiousFilterDaysSinceOnsetOfSymptomsFrom > key.DaysSinceOnsetOfSymptoms | ||
|| _infectiousFilterDaysSinceOnsetOfSymptomsTo < key.DaysSinceOnsetOfSymptoms | ||
) | ||
{ | ||
_logger.LogInformation($"key.DaysSinceOnsetOfSymptoms must be in {_infectiousFilterDaysSinceOnsetOfSymptomsFrom} to {_infectiousFilterDaysSinceOnsetOfSymptomsTo} but {key.DaysSinceOnsetOfSymptoms}"); | ||
return false; | ||
} | ||
} | ||
else | ||
{ | ||
_logger.LogDebug("diagnosis"); | ||
|
||
if (_infectiousFilterDaysSinceTestFrom > key.DaysSinceOnsetOfSymptoms | ||
|| _infectiousFilterDaysSinceTestTo < key.DaysSinceOnsetOfSymptoms | ||
) | ||
{ | ||
_logger.LogInformation($"key.DaysSinceOnsetOfSymptoms must be in {_infectiousFilterDaysSinceTestFrom} to {_infectiousFilterDaysSinceTestTo} but {key.DaysSinceOnsetOfSymptoms}"); | ||
return false; | ||
} | ||
} |
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.
症状の有無によってvalid/invalidを判定する
動作テストAzure Functionsの管理画面からConfigurationに次の値を設定した。
症状有りの場合は症状が現れた日から10日分のTEKが登録されること「症状有り」を選択した上で、次のTEKを診断キーとして登録した。
陽性情報登録完了後、Cosmos DBの TemporaryExposureKey[ 所見
症状無しの場合は検査日から7日分のTEKが登録されること「症状無し」を選択した上で、次のTEKを診断キーとして登録した。
陽性情報登録完了後、Cosmos DBの TemporaryExposureKey[ 所見
以上のことから、改修染みのV3DiagnosisApiは想定通り動作していると考えます。 |
|
Issue 番号 / Issue ID
目的 / Purpose
破壊的変更をもたらしますか / Does this introduce a breaking change?
Pull Request の種類 / Pull Request type
検証方法 / How to test
コードの入手 / Get the code
コードの検証 / Test the code
確認事項 / What to check
その他 / Other information
実装方針としては、次の通り。
運用中に値が変わることが想定されるため、Azure FunctionsのConfigurationに次の値を新しく追加した。
DaysSinceOnsetOfSymptom
の値の起点)DaysSinceOnsetOfSymptom
の値の終点)DaysSinceOnsetOfSymptom
の値の起点)DaysSinceOnsetOfSymptom
の値の終点)これらの値を変えることで、コードのリリース無しに、保存する(フィルターする)TEKの日付の範囲を運用レベルで変更できるようにしている。