public async Task CreateBackupWithShortSeed() { var seed = "11112222"; SetupDirectoriesAndReturnPath(seed); var ex = await Assert.ThrowsAsync <ArgumentException>(() => EdgeClient.CreateBackupAsync(EdgeContext, seed)); Assert.Equal(ex.Message, $"{nameof(seed)} should be 32 characters"); }
public async Task RetrieveLatestBackup() { var seed = "00000000000000000000000000000000"; SetupDirectoriesAndReturnPath(seed); await EdgeClient.CreateBackupAsync(EdgeContext, seed); var result = await EdgeClient.RetrieveBackupAsync(EdgeContext, seed); Assert.NotEmpty(result); Assert.IsType <Attachment>(result.First()); }
public async Task ListBackups() { // change backupId to be retrieved from provisioning service // Wait one second await Task.Delay(TimeSpan.FromSeconds(1)); var seed = "00000000000000000000000000000000"; SetupDirectoriesAndReturnPath(seed); await EdgeClient.CreateBackupAsync(EdgeContext, seed); var result = await EdgeClient.ListBackupsAsync(EdgeContext); Assert.NotEmpty(result); }
public async Task CreateBackup() { var seed = "00000000000000000000000000000000"; var path = SetupDirectoriesAndReturnPath(seed); await EdgeClient.CreateBackupAsync(EdgeContext, seed); var numDirsAfterBackup = Directory.GetDirectories(path).Length; var walletDir = Directory.GetDirectories(path).First(); var backupDir = Directory.GetDirectories(walletDir).First(); var backedUpWallet = Directory.GetFiles(backupDir).First(); Assert.True(Directory.Exists(path)); Assert.True(numDirsAfterBackup > 0); Assert.True(File.Exists(backedUpWallet)); }
public async Task RestoreAgentFromBackup() { var seed = "00000000000000000000000000000000"; var path = SetupDirectoriesAndReturnPath(seed); var myDid = await Did.CreateAndStoreMyDidAsync(EdgeContext.Wallet, "{}"); await EdgeClient.CreateBackupAsync(EdgeContext, seed); // Create a DID that we will retrieve and compare from imported wallet var attachments = await EdgeClient.RetrieveBackupAsync(EdgeContext, seed); await EdgeClient.RestoreFromBackupAsync(EdgeContext, seed, attachments); var newWallet = await WalletService.GetWalletAsync(AgentOptions.WalletConfiguration, AgentOptions.WalletCredentials); var myKey = await Did.KeyForLocalDidAsync(newWallet, myDid.Did); Assert.Equal(myKey, myDid.VerKey); }
private void GetEdgeClientID(out EdgeClient ClientDetails) { const string function = "CVRESTAPI::GetEdgeClientID"; ClientDetails = new EdgeClient(); string requestBody = string.Format(@"<App_LapTopClientListReq scope=""MyClients""><filter getUserMailBoxes=""true"" getSchedules=""false"" getContent=""false"" getMailBoxClients=""true"" getSharePointClients=""false"" getAllProperties=""true"" getFsLikeClients=""true"" /><user _type_=""USER_ENTITY"" userName=""{0}"" userId=""{1}"" userGUID=""{2}"" /></App_LapTopClientListReq>", Properties.Settings.Default.UserName, "", _userGuid); HttpWebResponse ClientResp = SendRequest(ServiceURI + "LaptopClientList", post, _authToken, requestBody); if (null != ClientResp && ClientResp.StatusCode == HttpStatusCode.OK) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(ClientResp.GetResponseStream()); XmlNode subClientNode = xmlDoc.SelectSingleNode(string.Format("/App_LapTopClientLstResp/clientsFileSystem[@clientStatus={0}]/subClient", CV_STATUS_EDGE_DRIVE)); if (null != subClientNode) { foreach (XmlAttribute attr in subClientNode.Attributes) { switch (attr.Name.ToLower()) { case "clientid": ClientDetails.ClientID = attr.Value; break; case "subclientid": ClientDetails.SubClientID = attr.Value; break; case "instanceid": ClientDetails.InstanceID = attr.Value; break; case "applicationid": ClientDetails.ApplicationID = attr.Value; break; default: break; } } subClientNode = xmlDoc.SelectSingleNode(string.Format("/App_LapTopClientLstResp/clientsFileSystem[@clientStatus={0}]/edgeDrive/@syncWebFolderId", CV_STATUS_EDGE_DRIVE)); if (null != subClientNode) { ClientDetails.RootWebFolderID = subClientNode.Value; } else { Logger.Warning("'edgeDrive' xml node not found in the web response.", function); } } else { Logger.Warning("'subClient' xml node node found in the web response.", function); } } else if (ClientResp != null && ClientResp.StatusCode == HttpStatusCode.Unauthorized) { string resultMsg; RenewToken(out resultMsg); } }