public void TestAuthorize() { var ctSource = new CancellationTokenSource(); ctSource.CancelAfter(5000); var api = FreeboxAPI.GetFreeboxApiInstance(appInfo, ctSource.Token).Result; var authorizeResult = api.Login.Authorize().Result; var authorizeTrack = api.Login.TrackAuthorization(authorizeResult.Result).Result; var ctAuth = new CancellationTokenSource(60000); while (authorizeTrack.Result.Status == AuthorizeStatus.Pending && !ctAuth.Token.IsCancellationRequested) { authorizeTrack = api.Login.TrackAuthorization(authorizeResult.Result).Result; Task.Delay(200).Wait(); } Assert.IsTrue(authorizeTrack.Result.Status == AuthorizeStatus.Granted || authorizeTrack.Result.Status == AuthorizeStatus.Denied || authorizeTrack.Result.Status == AuthorizeStatus.Unknown || (authorizeTrack.Result.Status == AuthorizeStatus.Pending && ctAuth.IsCancellationRequested)); System.Console.WriteLine(authorizeResult.Result.AppToken); }
public void GetFreeboxApiInstanceTest() { var ctSource = new CancellationTokenSource(); ctSource.CancelAfter(5000); var api = FreeboxAPI.GetFreeboxApiInstance(appInfo, ctSource.Token).Result; Assert.IsNotNull(api.ApiInfo.BoxModelName); }
public void TestLogin() { var ctSource = new CancellationTokenSource(); ctSource.CancelAfter(5000); var api = FreeboxAPI.GetFreeboxApiInstance(appInfo, ctSource.Token).Result; var appToken = this.Configuration.GetSection("app_token").Value; var r = api.Login.SessionOpen(appToken).Result; Assert.IsTrue(r.Success); Assert.IsTrue(api.Login.LoggedIn); }
public void TestAutoLogin() { var ctSource = new CancellationTokenSource(); ctSource.CancelAfter(5000); var api = FreeboxAPI.GetFreeboxApiInstance(appInfo, ctSource.Token).Result; // The session close method should clear the session token and indicate we are logged out, the test will evolve when it's the case var lo = api.RRD.GetRrd(new Fetch <Net>()).Result; Assert.IsFalse(string.IsNullOrWhiteSpace(api.Login.SessionToken)); Assert.IsTrue(api.Login.LoggedIn); Assert.IsTrue(lo.Success); }
public void TestLogout() { var ctSource = new CancellationTokenSource(); ctSource.CancelAfter(5000); var api = FreeboxAPI.GetFreeboxApiInstance(appInfo, ctSource.Token).Result; var r = api.Login.SessionOpen().Result; Assert.IsTrue(r.Success); var lo = api.Login.SessionClose().Result; Assert.IsTrue(lo.Success); Assert.IsTrue(string.IsNullOrWhiteSpace(api.Login.SessionToken)); Assert.IsFalse(api.Login.LoggedIn); Assert.IsTrue(lo.Success); }
public void TestContinuousRrd() { var ctSource = new CancellationTokenSource(); var api = FreeboxAPI.GetFreeboxApiInstance(appInfo, ctSource.Token).Result; var listRrd = new List <ApiResponse <RrdResponse <Net> > >(); ctSource.CancelAfter(120000); Task.Run(async() => { await foreach (var rrd in api.RRD.StreamRrd <Net>(RrdFields.NetRateDown | RrdFields.NetRateUp, ctSource.Token)) { listRrd.Add(rrd); } }).Wait(); Assert.IsTrue(listRrd.Count > 1); }
public void TestRrd() { var ctSource = new CancellationTokenSource(); ctSource.CancelAfter(5000); var api = FreeboxAPI.GetFreeboxApiInstance(appInfo, ctSource.Token).Result; var session = api.Login.SessionOpen().Result; Assert.IsTrue(session.Success); var rrd = api.RRD.GetRrd(new Fetch <Net> { DateStart = DateTime.Now.AddMinutes(-1), DateEnd = DateTime.Now, Fields = RrdFields.NetRateDown | RrdFields.NetRateUp | RrdFields.NetBwDown | RrdFields.NetBwUp }).Result; Assert.IsTrue(rrd.Success); Assert.IsTrue(rrd.Result.Data.Any(d => d.RateDown > 0)); Assert.IsTrue(api.Login.SessionClose().Result.Success); }
internal RRD(FreeboxAPI api) : base(api) { }
internal Login(FreeboxAPI api) : base(api) { }
public BaseModule(FreeboxAPI api) { this.FreeboxApi = api; }