Implement owner-scoped Observation lifecycle with serialized patches
This commit is contained in:
1 parent
bfe6ebf5af
commit
3a70e3e296
37 files changed
+31249
-9
No files matched your search
@@ -18,7 +18,7 @@ public class PatientApiFixture : IAsyncLifetime
|
||||
private string admin="";
|
||||
private WebApplicationFactory<HealthApp.Program>? host;
|
||||
public string ConnectionString {get;private set;}="";
|
||||
public string RuntimeConnectionString {get;private set;}="";
|
||||
public string RuntimeConnectionString {get;protected set;}="";
|
||||
public HttpClient Client {get;private set;}=null!;
|
||||
public HttpClient RawClient {get;private set;}=null!;
|
||||
public AuthenticatedTestClient Authentication {get;}=new();
|
||||
@@ -32,9 +32,9 @@ public class PatientApiFixture : IAsyncLifetime
|
||||
await using var db=new NpgsqlConnection(ConnectionString);await db.OpenAsync();
|
||||
var root=FindRoot();
|
||||
foreach(var _ in new[]{0,1})
|
||||
foreach(var script in Directory.GetFiles(Path.Combine(root,"src/Modules/Profile/Migrations"),"*.sql").Order())
|
||||
foreach(var script in new[]{"Profile","Observations"}.SelectMany(m=>Directory.GetFiles(Path.Combine(root,"src/Modules",m,"Migrations"),"*.sql").Order()))
|
||||
await new NpgsqlCommand(await File.ReadAllTextAsync(script),db).ExecuteNonQueryAsync();
|
||||
await new NpgsqlCommand($"REVOKE CREATE ON SCHEMA public FROM PUBLIC; GRANT CONNECT ON DATABASE {databaseName} TO {runtimeRole}; GRANT USAGE ON SCHEMA profile TO {runtimeRole}; GRANT SELECT,INSERT,UPDATE ON profile.patient TO {runtimeRole}; GRANT SELECT ON profile.schema_version TO {runtimeRole};",db).ExecuteNonQueryAsync();
|
||||
await new NpgsqlCommand($"REVOKE CREATE ON SCHEMA public FROM PUBLIC; GRANT CONNECT ON DATABASE {databaseName} TO {runtimeRole}; GRANT USAGE ON SCHEMA profile TO {runtimeRole}; GRANT SELECT,INSERT,UPDATE ON profile.patient TO {runtimeRole}; GRANT SELECT ON profile.schema_version TO {runtimeRole}; GRANT USAGE ON SCHEMA observations TO {runtimeRole}; GRANT SELECT,INSERT,UPDATE,DELETE ON observations.observation TO {runtimeRole}; GRANT SELECT ON observations.schema_version TO {runtimeRole};",db).ExecuteNonQueryAsync();
|
||||
RuntimeConnectionString=new NpgsqlConnectionStringBuilder(ConnectionString){Username=runtimeRole,Password="test-runtime-only"}.ConnectionString;
|
||||
Start();
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class PatientApiFixture : IAsyncLifetime
|
||||
});
|
||||
host.UseKestrel(0);RawClient=host.CreateClient();Client=Authentication.Wrap(RawClient);
|
||||
}
|
||||
public async Task RestartHostsAsync(){Client.Dispose();RawClient.Dispose();if(host is not null)await host.DisposeAsync();Start();}
|
||||
public virtual async Task RestartHostsAsync(){Client.Dispose();RawClient.Dispose();if(host is not null)await host.DisposeAsync();Start();}
|
||||
public async Task DisposeAsync()
|
||||
{
|
||||
Client?.Dispose();RawClient?.Dispose();if(host is not null)await host.DisposeAsync();
|
||||
|
||||
Reference in new issue
Block a user