Where did org.apache.cassandra.auth.Auth go in Cassandra 3? - java

We have an authenticator implementation which was made for Cassandra 2.1. There, we used org.apache.cassandra.auth.Auth#isSuperuser() method to see whether the user is superuser or not.
In Cassandra 3 (namely 3.11.2), there is no org.apache.cassandra.auth.Auth class, and I could not find any isSuperuser() static method in it.
Is it still possible to achieve the same goal (determine whether a user is a superuser or not)? If not, what is the correct way to do it in Cassandra 3?
The artifact I'm using is cassandra-all.

It turned out to be easy:
new AuthenticatedUser(username).isSuper()
This determines whether the user with login username is a superuser.

Related

Cucumber: best way to generate test data? and store it for future use?

I'm still pretty new to Cucumber automation testing and I haven't found anything about this in documentation, so I'm guessing either it's not possible or it's done in a very different way.
The thing is, in Robot automation framework I'm used to working with variables like this: ${userName} and once set these can be shared by different tests. Is that possible in cucumber?
The specific use case is: I'm using Java version of Cucumber, and I want to create a new user account that I'll use throughout all scenarios in the whole feature file:
Scenario: Create user account
Given user navigates to the home page
And user enters username and password *(this is where I want to provide random data and have it stored for future use)*
And user clicks on the register button
Then user should see the default landing page
I can always create a random user name and password in my test implementation using java and store them in class-scoped variables for future use in all steps that require them. But I'm not sure this is a good practice. Is there a better way to do so?
To generate a user and password, you'll have to implement this yourself, as stated by #Eugene S.
To share variables between steps, it is best to use Dependency Injection. Cucumber-jvm supports multiple DI frameworks, as listed here: https://cucumber.io/docs/reference/java-di
Unfortunately there isn't a lot of "official" (Cucumber) documentation on how to do this.
Thomas Sundberg has written several blog posts on how to share variables between steps using different DI frameworks, including:
PicoContainer: http://www.thinkcode.se/blog/2017/04/01/sharing-state-between-steps-in-cucumberjvm-using-picocontainer
Spring: http://www.thinkcode.se/blog/2017/06/24/sharing-state-between-steps-in-cucumberjvm-using-spring
Guice: http://www.thinkcode.se/blog/2017/08/16/sharing-state-between-steps-in-cucumberjvm-using-guice
Random user and password is not really necessary. Read please Equivalence Class Testing vs. Boundary Value Testing
You can create your wildcards for variables:
`And user enters username and password "VAR#:username" "VAR#:password"`
`#Given("^user enters username and password$")
public void getCredentials(String userName, String password) {
userName = DataStore.getValue(userName);
password = DataStore.getValue(password);
}`
Inside dataStore you can get values from property file or anything else.
property file can look like:
VAR#:username=Username
VAR#:password=1234
No, Cucumber does not allow anything like that. The only thing Cucumber does, is parse your steps and run the matching methods.
To achieve what you describe you can just create a method that will somehow encapsulate data and variable that you require. Then you can run this step in order to obtain it.
For example take the step that you described:
And user enters username and password
Then the method that will be executed will look something like:
#Given("^user enters username and password$")
public void getCredentials() {
//for example
userName = SomeStaticClaass.getUsername();
password = SomeStaticClaass.getPassword();
}

How can I change the owner of a print job in Java

Is there a way to set the print job owner when printing from a Java program?
From what I have been able to find, I think this may not be possible for security reasons - that doing so means I can impersonate another user.
thanks - dave

JIRA Rest API DELETE call for removing user/actor is not removing users

We are using REST APIs to remove users from the actor roles of Projects.
We are using DELETE call for removing user/actor from the roles from a project.
JIRA call (Delete)
https:///rest/api/2/project/11264/role/10100?user=
REST API referring to,
https://docs.atlassian.com/jira/REST/7.0.10/#api/2/project/{projectIdOrKey}/role-deleteActor
The API returns 204 status message, but the user/actor is not removed from the Project.
I have tried this using JAVA, REST Clients
Has anyone experience this behaviour. If yes, could you please guide me on this.
I ran into this too and submitted a support request to Atlassian. They told me the delete actor endpoint uses the user_key which is the lowercase version of the first username the user ever had.
Check the fault report at https://jira.atlassian.com/browse/JRASERVER-68189 for more detail.
The userkey can be found for a username by calling /rest/api/2/user?username= which includes the key in its response.
your call should be like this
https:/<JIRA_URL>/rest/api/2/project/<Project-KEY>/role/10100?user=<username>
eg.
https://myjira.uat.com:8443/rest/api/2/project/SAND/role/10700?user=amitraj
Yes, Jira always returns 204 regardless if user is removed or not, sadly.
Unfortunately, in some cases, the user is not removed (altough projectKey, roleId and userName are definitely correct. This happens approx. for 1/20 calls and I don't why.
To make sure if the user has been really deleted I run another API call to check project role members after deletion:
/rest/api/2/project/{projectIdOrKey}/role/{id}
I'm running Jira 7.3.6 and using REST API with Python.
Not sure if removing users using ScriptRunner and Groovy would be better but I don't want to rewrite whole script into a different environment.
I had the same issue with one user, and I just noticed that passing a lowercase username does work (JIRA+Crowd in our setup). Always using lowercase should be fine according to the documentation, though it should work in all cases.

Proper use cases for Android ActivityManager.isUserAMonkey()?

I was looking at the new APIs introduced in Android 2.2. While looking at the ActivityManager class I came across the following method:
public static boolean isUserAMonkey()
Used to determine whether the user making this call is subject to teleportations.
Returns whether the user making this call is a monkey.
How and when should this be used?
as per android docs
Returns "true" if the user interface is currently being messed with by a monkey.
to know the application is testing using monkey or not
well if you do some automatic testing there will be test users. this method checks if the current user is such a test user.
about how to use it there are already a lot of topics, see:
clickMe

XPages getEffectiveUserName()

I'm using an XPage as an agent (XAgent) which makes an SSJS call into some Java classes stored as Java design elements. I want the processes which are instigated by the XPage to be in the context of the user I'm currently signed into the browser as. However everything seems to be running as me, I guess based on the last signature on the XPage?
For example, in my custom classes the following returns my name when I need it to be returning the user's name:
DominoUtils.getCurrentSession().getEffectiveUserName()
When using old school Domino agents, the effective username is determined by the "Run as Web User" or "Run on behalf of" fields in the agent properties.
Is it possible to achieve the same functionality when using an XPage?
To investigate you have a number of moving parts:
Add to the XAgent (not your Java code) a print statement with session.getUserName() and session.getEffectiveUsername()
Check your DominoUtils if there is a sessionAsSigner hidden in it
if 1 works, but not 3, consider dependency injection: instead of getting the session from DominoUtils hand it over as parameter from the XAgent to the Java class
Let us know how it goes
In my scenarios I could solve most of the requirements with either:
session.getEffectiveUserName()
or:
context.getUser().getFullName()
There are situations where you need to encapsulate this with:
session.createName(string):NotesName
to get the NotesName-Object representation.

Categories