//~ func TestFormatResponseErrors(t *testing.T) { public void TestFormatResponseErrors() { //~ salter, _ := salt.NewSalt(nil, nil) //~ config := FormatterConfig{ //~ Salt: salter, //~ } //~ formatter := AuditFormatter{ //~ AuditFormatWriter: &noopFormatWriter{}, //~ } var salter = Salt.NewSalt(null, null); var config = new FormatterConfig { Salt = salter, }; var formatter = new AuditFormatter(new noopFormatWriter()); //~ if err := formatter.FormatResponse(ioutil.Discard, config, nil, nil, nil, nil); err == nil { //~ t.Fatal("expected error due to nil request") //~ } //~ if err := formatter.FormatResponse(nil, config, nil, &logical.Request{}, nil, nil); err == nil { //~ t.Fatal("expected error due to nil writer") //~ } Assert.ThrowsException <ArgumentNullException>(() => formatter.FormatResponse(Stream.Null, config, null, null, null, null)); Assert.ThrowsException <ArgumentNullException>(() => formatter.FormatResponse(null, config, null, new Logical.Request(), null, null)); }
//~ func TestHashString(t *testing.T) { public void TestHashString() { //~ inmemStorage := &logical.InmemStorage{} //~ inmemStorage.Put(&logical.StorageEntry{ //~ Key: "salt", //~ Value: []byte("foo"), //~ }) var inmemStorage = new Logical.InmemStorage(); inmemStorage.Put(new Logical.StorageEntry { Key = "salt", Value = "foo".ToUtf8Bytes(), }); //~ localSalt, err := salt.NewSalt(inmemStorage, &salt.Config{ //~ HMAC: sha256.New, //~ HMACType: "hmac-sha256", //~ }) var localSalt = Salt.NewSalt(inmemStorage, new Config { HMAC = () => new HMACSHA256(), HMACType = "hmac-sha256", }); //~ if err != nil { //~ t.Fatalf("Error instantiating salt: %s", err) //~ } //~ out := HashString(localSalt, "foo") //~ if out != "hmac-sha256:08ba357e274f528065766c770a639abf6809b39ccfd37c2a3157c7f51954da0a" { //~ t.Fatalf("err: HashString output did not match expected") //~ } var @out = HashStructure.HashString(localSalt, "foo"); Assert.AreEqual("hmac-sha256:08ba357e274f528065766c770a639abf6809b39ccfd37c2a3157c7f51954da0a", @out.ToLower()); }