public async Task Should_not_compute_ui_tokens_for_frontend() { var source = CreateContent(); await sut.EnrichAsync(new Context(Mocks.FrontendUser(), Mocks.App(appId)), new[] { source }, schemaProvider, default); Assert.Null(source.EditToken); A.CallTo(() => urlGenerator.Root()) .MustNotHaveHappened(); }
public async Task Should_not_compute_ui_tokens_for_frontend() { var source = new AssetEntity { AppId = appId }; var result = await sut.EnrichAsync(new[] { source }, new Context(Mocks.FrontendUser(), Mocks.App(appId)), default); Assert.Null(result[0].EditToken); A.CallTo(() => urlGenerator.Root()) .MustNotHaveHappened(); }
public Task EnrichAsync(Context context, IEnumerable <ContentEntity> contents, ProvideSchema schemas, CancellationToken ct) { if (context.IsFrontendClient) { return(Task.CompletedTask); } var url = urlGenerator.Root(); foreach (var content in contents) { var token = new { a = content.AppId.Name, s = content.SchemaId.Name, i = content.Id.ToString(), u = url }; var json = jsonSerializer.Serialize(token); content.EditToken = Convert.ToBase64String(Encoding.UTF8.GetBytes(json)); } return(Task.CompletedTask); }
private void ComputeTokens(IEnumerable <IEnrichedAssetEntity> assets) { var url = urlGenerator.Root(); foreach (var asset in assets) { var token = new { a = asset.AppId.Name, i = asset.Id.ToString(), u = url }; var json = jsonSerializer.Serialize(token); asset.EditToken = Convert.ToBase64String(Encoding.UTF8.GetBytes(json)); } }
private ISession CreateSession(IAppEntity app) { var client = app.Clients.First(); var url = templateOptions.LocalUrl; if (string.IsNullOrEmpty(url)) { url = urlGenerator.Root(); } return(new Session( app.Name, new DirectoryInfo(Path.GetTempPath()), new SquidexClientManager(new SquidexOptions { Configurator = AcceptAllCertificatesConfigurator.Instance, AppName = app.Name, ClientId = $"{app.Name}:{client.Key}", ClientSecret = client.Value.Secret, Url = url }))); }