public async Task HandleCreateIdentityResultCallbackAsync(NDIDCallbackIdentityModel model) { if (model.IsSuccess) { string sid = _db.GetReferecne(model.ReferenceId, "sid"); string[] parts = sid.Split('-'); NDIDUserModel user = new NDIDUserModel(); user.NameSpace = parts[0]; user.Identifier = parts[1]; string accessor_id = _db.GetReferecne(model.ReferenceId, "accessor_id"); NDIDAccessorModel accessor = new NDIDAccessorModel(); accessor.AccessorId = accessor_id; accessor.Secret = model.Secret; // update key string newKeyName = sid + "-" + "0"; // not use base64 file name because windows cannot support filename with "/" charactor _dpki.UpdateKey(sid, newKeyName); string pubKey = await _dpki.GetPubKey(newKeyName); accessor.AccessorPubKey = pubKey; user.Accessors.Add(accessor); // save new user _db.CreateNewUser(user); // remove all referenceId _db.RemoveReference(model.ReferenceId); } else { throw new ApplicationException(); } }
public void SaveAndFindNDIDUser() { NDIDUserModel user = new NDIDUserModel(); user.NameSpace = "cid"; user.Identifier = "1234"; user.Accessors.Add(new NDIDAccessorModel { AccessorId = "hello", Secret = "this should be secret" }); long id = _db.CreateNewUser(user); NDIDUserModel retrievedUser = _db.FindUser(user.NameSpace, user.Identifier); retrievedUser.Should().BeEquivalentTo <NDIDUserModel>(user); }