-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from VOLTTRON/feature/env-publickey
Feature add environmental key suppport
- Loading branch information
Showing
6 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
|
||
import mock | ||
import pytest | ||
|
||
from volttron.utils import vip_main | ||
|
||
|
||
class AgentMockery: | ||
myargs = None | ||
mykwargs = None | ||
|
||
def __init__(self, *args, **kwargs): | ||
AgentMockery.myargs = args | ||
AgentMockery.mykwargs = kwargs | ||
|
||
def run(self): | ||
pass | ||
|
||
|
||
def test_env_args_passed_to_agent(): | ||
env = dict(AGENT_PUBLICKEY="uSo_q3vw-DpcOeCOXc1A4o1U11qpTtkkW2EviHM7x24", | ||
AGENT_SECRETKEY="WpnCmf1vM1Z5gw0uIg8tr2C4erNQpSa0KONq9NvjzUE", | ||
VOLTTRON_SERVERKEY="UH4tX5RDNTMjp5VPxVuj-M5QiO82BLUghYeWJ_CgvQc") | ||
with mock.patch.dict(os.environ, env): | ||
vip_main(AgentMockery, identity="foo") | ||
assert env["AGENT_PUBLICKEY"] == AgentMockery.mykwargs['publickey'] | ||
assert env["AGENT_SECRETKEY"] == AgentMockery.mykwargs['secretkey'] | ||
assert env["VOLTTRON_SERVERKEY"] == AgentMockery.mykwargs['serverkey'] | ||
|
||
|
||
def test_env_only_publickey_passed_to_agent(): | ||
env = dict(AGENT_PUBLICKEY="uSo_q3vw-DpcOeCOXc1A4o1U11qpTtkkW2EviHM7x24") | ||
with mock.patch.dict(os.environ, env): | ||
with pytest.raises(ValueError): | ||
vip_main(AgentMockery, identity="foo") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters