public void APISavesToSecondaryPings() { Private.JweMetricType jweMetric = new Private.JweMetricType( category: "telemetry", disabled: false, lifetime: Private.Lifetime.Application, name: "jwe_metric", sendInPings: new string[] { "store1", "store2" } ); // Record two JWEs of the same type, with a little delay. jweMetric.Set(this.header, this.key, this.initVector, this.cipherText, this.authTag); // Check that data was properly recorded in the second ping. Assert.True(jweMetric.TestHasValue("store2")); Assert.Equal(this.jwe, jweMetric.testGetCompactRepresentation("store2")); jweMetric.Set(this.header, "", "", this.cipherText, ""); // Check that data was properly recorded in the second ping. Assert.True(jweMetric.TestHasValue("store2")); Assert.Equal(this.minimumJwe, jweMetric.testGetCompactRepresentation("store2")); }
public void DisabledJwesMustNotRecordData() { Private.JweMetricType jweMetric = new Private.JweMetricType( category: "telemetry", disabled: true, lifetime: Private.Lifetime.Application, name: "jwe_metric", sendInPings: new string[] { "store1" } ); // Attempt to store the string. jweMetric.Set(this.header, this.key, this.initVector, this.cipherText, this.authTag); // Check that nothing was recorded. Assert.False(jweMetric.TestHasValue(), "JWEs must not be recorded if they are disabled"); }
public void SettingALongStringRecordsAnError() { Private.JweMetricType jweMetric = new Private.JweMetricType( category: "telemetry", disabled: false, lifetime: Private.Lifetime.Application, name: "jwe_metric", sendInPings: new string[] { "store1", "store2" } ); // Too long elements should yield a InvalidOverflow error jweMetric.Set(new string('X', 1025), this.key, this.initVector, this.cipherText, this.authTag); Assert.Equal(1, jweMetric.TestGetNumRecordedErrors(ErrorType.InvalidOverflow)); // Invalid compact string representation yield a InvalidValue error jweMetric.setWithCompactRepresentation(""); Assert.Equal(1, jweMetric.TestGetNumRecordedErrors(ErrorType.InvalidValue)); }
public void TestJweGetValueReturnsCorrectJweDataRepresentation() { Private.JweMetricType jweMetric = new Private.JweMetricType( category: "telemetry", disabled: false, lifetime: Private.Lifetime.Application, name: "jwe_metric", sendInPings: new string[] { "store1" } ); jweMetric.Set(this.header, this.key, this.initVector, this.cipherText, this.authTag); Private.JweData data = jweMetric.TestGetValue(); Assert.Equal(data.Header, this.header); Assert.Equal(data.Key, this.key); Assert.Equal(data.InitVector, this.initVector); Assert.Equal(data.CipherText, this.cipherText); Assert.Equal(data.AuthTag, this.authTag); }