功能修改
This commit is contained in:
@@ -96,6 +96,42 @@ func TestCoreServiceGeneratesRunDistributionWithEncryptedSingletonKey(t *testing
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceRuntimeActionsGateDependenciesOnPluginPermission(t *testing.T) {
|
||||
svc, session, instance := newDistributionTestFixture(t)
|
||||
plugin, err := svc.store.GamePlugins().Get(instance.PluginID)
|
||||
if err != nil {
|
||||
t.Fatalf("get plugin: %v", err)
|
||||
}
|
||||
permissions := plugin.DeclaredPermissions[:0]
|
||||
for _, permission := range plugin.DeclaredPermissions {
|
||||
if permission != "server.dependencies.manage" {
|
||||
permissions = append(permissions, permission)
|
||||
}
|
||||
}
|
||||
plugin.DeclaredPermissions = permissions
|
||||
if err := svc.store.GamePlugins().Update(plugin); err != nil {
|
||||
t.Fatalf("update plugin: %v", err)
|
||||
}
|
||||
|
||||
actions, err := svc.GetServerRuntimeActionsForSession(session, instance.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("get runtime actions: %v", err)
|
||||
}
|
||||
seen := 0
|
||||
for _, action := range actions.Actions {
|
||||
if action.Key != "dependencies-check" && action.Key != "dependencies-install" {
|
||||
continue
|
||||
}
|
||||
seen++
|
||||
if action.Available || action.Reason != "plugin permission is not declared" {
|
||||
t.Fatalf("expected dependency action gated by plugin permission, got %+v", action)
|
||||
}
|
||||
}
|
||||
if seen != 2 {
|
||||
t.Fatalf("expected both dependency actions in %+v", actions.Actions)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceDistributionBuildRejectsPrematureSuccessAndCanRetryAfterUpload(t *testing.T) {
|
||||
svc, session, instance := newDistributionTestFixture(t)
|
||||
distribution, err := svc.GenerateRunDistributionForSession(session, domain.RunDistributionGenerateRequest{
|
||||
|
||||
Reference in New Issue
Block a user