Fixed a bug where key value pair was not returning data correctly when get_by_name function is called.
Bug: Calling 'get_by_name' on client for getting key details was not returning any results despite key being stored. Following is the sample code for replicating the bug
from st2common.runners.base_action import Action
from st2client.client import Client
class actionContext(Action):
def run(self):
client = Client(base_url='http://localhost')
result = client.keys.get_by_name(name='test_key',scope='user')
self.logger.debug(result)
return result
Resolution: 'keys' property in Client is of type 'ResourceManager'. We created a new class 'KeyValuePairResourceManager' which inherits from 'ResourceManager'. We assigned 'KeyValuePairResourceManager' to 'keys' property. We have created get_by_name in this class. KeyValuePairResourceManager's get_by_name calls "/keys/{keyname}" url while the old function used to call '/keys' url. We looked into test cases for classes which inherit from 'ResourceManager' but did not find any. There are test cases for functions in 'ResourceManager' but not for classes inheriting from it. But we wrote a unit test case which tests KeyValuePairResourceManager's get_by_name function
Resubmitted the PR with correct credentials.
Can anyone help me on how to add changes to CHANGELOG.rst? Do I need to run some command like make lint?
@bharath-orchestral Thanks for working on this!
Here is the changelog: https://github.com/StackStorm/st2/blob/master/CHANGELOG.rst There isn't a command that auto-generates a changelog entry (though I wish we had that). Here is an example of a adding a changelog entry: https://github.com/StackStorm/st2/commit/8e908a5435a5a70a80d7fb4839e2fb8a663b1a6c
For this PR, you will need to put your changelog entry under In Development (at the top of the file) at the end of the list of Fixed issues.
To run the black formatter you can use make black.
Deleting that init.py file also removed the folders it was in, so now there are failures in some unit tests. Could you restore that please? Or a .gitkeep file would probably work
I added that init.py in that folder but for some reason orquesta CI/ Integration Tests are failing. @cognifloyd Do you know the reason for this?