Skip to content

Commit 533e946

Browse files
committed
Test with default HTTP authentication rather than anonymous
1 parent 6c13d82 commit 533e946

File tree

74 files changed

+76
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+76
-73
lines changed

azure/worker/testutils.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,33 @@
4141
WORKER_PATH = pathlib.Path(__file__).parent.parent.parent
4242
WORKER_CONFIG = WORKER_PATH / '.testconfig'
4343

44+
SECRETS_TEMPLATE = """\
45+
{
46+
"masterKey": {
47+
"name": "master",
48+
"value": "testMasterKey",
49+
"encrypted": false
50+
},
51+
"functionKeys": [
52+
{
53+
"name": "default",
54+
"value": "testFunctionKey",
55+
"encrypted": false
56+
}
57+
],
58+
"systemKeys": [
59+
{
60+
"name": "eventgridextensionconfig_extension",
61+
"value": "testSystemKey",
62+
"encrypted": false
63+
}
64+
],
65+
"hostName": null,
66+
"instanceId": "0000000000000000000000001C69C103",
67+
"source": "runtime"
68+
}
69+
"""
70+
4471

4572
class AsyncTestCaseMeta(type(unittest.TestCase)):
4673

@@ -413,7 +440,11 @@ def __init__(self, proc, addr):
413440

414441
def request(self, meth, funcname, *args, **kwargs):
415442
request_method = getattr(requests, meth.lower())
416-
return request_method(self._addr + '/api/' + funcname, *args, **kwargs)
443+
params = dict(kwargs.pop('params', {}))
444+
if 'code' not in params:
445+
params['code'] = 'testFunctionKey'
446+
return request_method(self._addr + '/api/' + funcname,
447+
*args, params=params, **kwargs)
417448

418449
def close(self):
419450
if self._proc.stdout:
@@ -449,6 +480,12 @@ def popen_webhost(*, stdout, stderr, script_root=FUNCS_PATH, port=None):
449480
if not dll:
450481
dll = DEFAULT_WEBHOST_DLL_PATH
451482

483+
secrets = SECRETS_TEMPLATE
484+
485+
os.makedirs(dll.parent / 'Secrets', exist_ok=True)
486+
with open(dll.parent / 'Secrets' / 'host.json', 'w') as f:
487+
f.write(secrets)
488+
452489
if not dll or not pathlib.Path(dll).exists():
453490
raise RuntimeError('\n'.join([
454491
f'Unable to locate Azure Functions Host binary.',
@@ -533,7 +570,8 @@ def start_webhost(*, script_dir=None, stdout=None):
533570

534571
for n in range(10):
535572
try:
536-
r = requests.get(f'{addr}/api/ping')
573+
r = requests.get(f'{addr}/api/ping',
574+
params={'code': 'testFunctionKey'})
537575
if 200 <= r.status_code < 300:
538576
# Give the host a bit more time to settle
539577
time.sleep(1)

tests/blob_functions/get_blob_bytes/function.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"disabled": false,
44
"bindings": [
55
{
6-
"authLevel": "anonymous",
76
"type": "httpTrigger",
87
"direction": "in",
98
"name": "req"

tests/blob_functions/get_blob_filelike/function.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"disabled": false,
44
"bindings": [
55
{
6-
"authLevel": "anonymous",
76
"type": "httpTrigger",
87
"direction": "in",
98
"name": "req"

tests/blob_functions/get_blob_return/function.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"disabled": false,
44
"bindings": [
55
{
6-
"authLevel": "anonymous",
76
"type": "httpTrigger",
87
"direction": "in",
98
"name": "req"

tests/blob_functions/get_blob_str/function.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"disabled": false,
44
"bindings": [
55
{
6-
"authLevel": "anonymous",
76
"type": "httpTrigger",
87
"direction": "in",
98
"name": "req"

tests/blob_functions/get_blob_triggered/function.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"disabled": false,
44
"bindings": [
55
{
6-
"authLevel": "anonymous",
76
"type": "httpTrigger",
87
"direction": "in",
98
"name": "req"

tests/blob_functions/ping/function.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"disabled": false,
44
"bindings": [
55
{
6-
"authLevel": "anonymous",
76
"type": "httpTrigger",
87
"direction": "in",
98
"name": "req"

tests/blob_functions/put_blob_bytes/function.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"disabled": false,
44
"bindings": [
55
{
6-
"authLevel": "anonymous",
76
"type": "httpTrigger",
87
"direction": "in",
98
"name": "req"

tests/blob_functions/put_blob_filelike/function.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"disabled": false,
44
"bindings": [
55
{
6-
"authLevel": "anonymous",
76
"type": "httpTrigger",
87
"direction": "in",
98
"name": "req"

tests/blob_functions/put_blob_return/function.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"disabled": false,
44
"bindings": [
55
{
6-
"authLevel": "anonymous",
76
"type": "httpTrigger",
87
"direction": "in",
98
"name": "req"

0 commit comments

Comments
 (0)