Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-server
Commits
fd0ed36e
Commit
fd0ed36e
authored
1 week ago
by
Joscha Schmiedt
Browse files
Options
Downloads
Patches
Plain Diff
Remove attempts for integration tests for SSS in gRPC
parent
1978c38c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!121
Draft: Add server side scripting to gRPC API
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/org/caosdb/server/grpc/ServerSideScriptingGrpcTest.java
+0
-196
0 additions, 196 deletions
...a/org/caosdb/server/grpc/ServerSideScriptingGrpcTest.java
with
0 additions
and
196 deletions
src/test/java/org/caosdb/server/grpc/ServerSideScriptingGrpcTest.java
+
0
−
196
View file @
fd0ed36e
...
@@ -22,180 +22,14 @@ package org.caosdb.server.grpc;
...
@@ -22,180 +22,14 @@ package org.caosdb.server.grpc;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.subject.Subject
;
import
org.caosdb.api.scripting.v1alpha1.ExecuteServerSideScriptRequest
;
import
org.caosdb.api.scripting.v1alpha1.ExecuteServerSideScriptRequest
;
import
org.caosdb.api.scripting.v1alpha1.ExecuteServerSideScriptResponse
;
import
org.caosdb.api.scripting.v1alpha1.NamedArgument
;
import
org.caosdb.api.scripting.v1alpha1.NamedArgument
;
import
org.caosdb.api.scripting.v1alpha1.ServerSideScriptExecutionResult
;
import
org.caosdb.server.CaosDBServer
;
import
org.caosdb.server.ServerProperties
;
import
org.caosdb.server.accessControl.AnonymousAuthenticationToken
;
import
org.caosdb.server.accessControl.CredentialsValidator
;
import
org.caosdb.server.accessControl.Principal
;
import
org.caosdb.server.accessControl.Role
;
import
org.caosdb.server.accessControl.UserSources
;
import
org.caosdb.server.database.BackendTransaction
;
import
org.caosdb.server.database.access.Access
;
import
org.caosdb.server.database.backend.interfaces.RetrievePasswordValidatorImpl
;
import
org.caosdb.server.database.backend.interfaces.RetrievePermissionRulesImpl
;
import
org.caosdb.server.database.backend.interfaces.RetrieveRoleImpl
;
import
org.caosdb.server.database.backend.interfaces.RetrieveUserImpl
;
import
org.caosdb.server.database.exceptions.TransactionException
;
import
org.caosdb.server.database.misc.TransactionBenchmark
;
import
org.caosdb.server.database.proto.ProtoUser
;
import
org.caosdb.server.entity.Message
;
import
org.caosdb.server.entity.Message
;
import
org.caosdb.server.permissions.PermissionRule
;
import
org.caosdb.server.scripting.ScriptingPermissions
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
public
class
ServerSideScriptingGrpcTest
{
public
class
ServerSideScriptingGrpcTest
{
public
static
class
RetrieveRoleMockup
implements
RetrieveRoleImpl
{
public
RetrieveRoleMockup
(
Access
a
)
{}
@Override
public
Role
retrieve
(
String
role
)
throws
TransactionException
{
Role
ret
=
new
Role
();
ret
.
name
=
"anonymous"
;
ret
.
description
=
"bla"
;
return
ret
;
}
@Override
public
TransactionBenchmark
getBenchmark
()
{
return
null
;
}
@Override
public
void
setTransactionBenchmark
(
TransactionBenchmark
b
)
{}
}
public
static
class
RetrievePermissionRules
implements
RetrievePermissionRulesImpl
{
public
RetrievePermissionRules
(
Access
a
)
{}
@Override
public
HashSet
<
PermissionRule
>
retrievePermissionRule
(
String
role
)
throws
TransactionException
{
HashSet
<
PermissionRule
>
result
=
new
HashSet
<>();
result
.
add
(
new
PermissionRule
(
true
,
false
,
ScriptingPermissions
.
PERMISSION_EXECUTION
(
"anonymous_ok"
)));
return
result
;
}
@Override
public
TransactionBenchmark
getBenchmark
()
{
return
null
;
}
@Override
public
void
setTransactionBenchmark
(
TransactionBenchmark
b
)
{}
}
public
static
class
RetrieveUserMockUp
implements
RetrieveUserImpl
{
public
RetrieveUserMockUp
(
Access
a
)
{}
@Override
public
ProtoUser
execute
(
Principal
principal
)
throws
TransactionException
{
return
new
ProtoUser
();
}
@Override
public
TransactionBenchmark
getBenchmark
()
{
return
null
;
}
@Override
public
void
setTransactionBenchmark
(
TransactionBenchmark
b
)
{}
}
public
static
class
RetrievePasswordValidator
implements
RetrievePasswordValidatorImpl
{
public
RetrievePasswordValidator
(
Access
a
)
{}
@Override
public
CredentialsValidator
<
String
>
execute
(
String
name
)
throws
TransactionException
{
return
new
CredentialsValidator
<
String
>()
{
@Override
public
boolean
isValid
(
String
credential
)
{
return
true
;
}
};
}
@Override
public
void
setTransactionBenchmark
(
TransactionBenchmark
b
)
{}
@Override
public
TransactionBenchmark
getBenchmark
()
{
return
null
;
}
}
@BeforeAll
public
static
void
setupShiro
()
throws
IOException
{
CaosDBServer
.
initServerProperties
();
CaosDBServer
.
initShiro
();
BackendTransaction
.
setImpl
(
RetrieveRoleImpl
.
class
,
RetrieveRoleMockup
.
class
);
BackendTransaction
.
setImpl
(
RetrievePermissionRulesImpl
.
class
,
RetrievePermissionRules
.
class
);
BackendTransaction
.
setImpl
(
RetrieveUserImpl
.
class
,
RetrieveUserMockUp
.
class
);
BackendTransaction
.
setImpl
(
RetrievePasswordValidatorImpl
.
class
,
RetrievePasswordValidator
.
class
);
UserSources
.
getDefaultRealm
();
}
@Test
public
void
testAnonymousWithOutPermission
()
{
Subject
user
=
SecurityUtils
.
getSubject
();
CaosDBServer
.
setProperty
(
ServerProperties
.
KEY_AUTH_OPTIONAL
,
"true"
);
user
.
login
(
AnonymousAuthenticationToken
.
getInstance
());
// TODO: implement this test
// Form form = new Form("call=anonymous_no_permission");
// Representation entity = form.getWebRepresentation();
// Request request = new Request(Method.POST, "../test", entity);
// request.setRootRef(new Reference("bla"));
// request.getAttributes().put("SRID", "asdf1234");
// request.setDate(new Date());
// request.setHostRef("bla");
// resource.init(null, request, new Response(null));
// resource.handle();
// assertEquals(Status.CLIENT_ERROR_FORBIDDEN,
// resource.getResponse().getStatus());
}
@Test
public
void
testAnonymousWithPermission
()
{
Subject
user
=
SecurityUtils
.
getSubject
();
CaosDBServer
.
setProperty
(
ServerProperties
.
KEY_AUTH_OPTIONAL
,
"true"
);
user
.
login
(
AnonymousAuthenticationToken
.
getInstance
());
// TODO: implement this test
// Form form = new Form("call=anonymous_ok");
// Representation entity = form.getWebRepresentation();
// Request request = new Request(Method.POST, "../test", entity);
// request.setRootRef(new Reference("bla"));
// request.getAttributes().put("SRID", "asdf1234");
// request.setDate(new Date());
// request.setHostRef("bla");
// resource.init(null, request, new Response(null));
// resource.handle();
// assertEquals(Status.SUCCESS_OK, resource.getResponse().getStatus());
}
@Test
@Test
public
void
testExecuteServerSideScriptRequestToCommandline
()
throws
Message
{
public
void
testExecuteServerSideScriptRequestToCommandline
()
throws
Message
{
ExecuteServerSideScriptRequest
request
=
ExecuteServerSideScriptRequest
request
=
...
@@ -218,34 +52,4 @@ public class ServerSideScriptingGrpcTest {
...
@@ -218,34 +52,4 @@ public class ServerSideScriptingGrpcTest {
assertEquals
(
commandline
.
get
(
3
),
"pos0"
);
assertEquals
(
commandline
.
get
(
3
),
"pos0"
);
assertEquals
(
commandline
.
get
(
4
),
"pos1"
);
assertEquals
(
commandline
.
get
(
4
),
"pos1"
);
}
}
@Test
public
void
testCallScript
()
throws
Message
{
// TODO: Implement this test
// ServerSideScriptingServiceImpl service = new ServerSideScriptingServiceImpl();
// ExecuteServerSideScriptRequest request =
// ExecuteServerSideScriptRequest.newBuilder()
// .setScriptFilename("my_script.py")
// .addPositionalArguments("pos0")
// .addPositionalArguments("pos1")
// .addNamedArguments(
// NamedArgument.newBuilder().setName("option1").setValue("val1").build())
// .addNamedArguments(
// NamedArgument.newBuilder().setName("option2").setValue("val2").build())
// .setTimeoutMs(1000)
// .build();
// ExecuteServerSideScriptResponse response = service.callScript(request);
// assertEquals(response.getCall(), "my_script.py");
// assertEquals(
// response.getResult(),
// ServerSideScriptExecutionResult.SERVER_SIDE_SCRIPT_EXECUTION_RESULT_SUCCESS);
// assertEquals(response.getStdout(), ""); // Assuming the script does not produce any output
// assertEquals(response.getStderr(), ""); // Assuming the script does not produce any error output
// assertEquals(response.getReturnCode(), 0); // Assuming the script returns 0
// assertEquals(response.getDurationMs() > 0, true); // Check if duration is greater than 0
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment