Commit 5f68aba 1 parent 8932be4 commit 5f68aba Copy full SHA for 5f68aba
File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 3
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
4
import uuid
5
5
6
- from pathlib import Path
7
6
8
7
import quart .flask_patch
9
8
from quart import Quart , request , current_app
Original file line number Diff line number Diff line change
1
+ # This Source Code Form is subject to the terms of the Mozilla Public
2
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
+
5
+ import unittest
6
+ from pathlib import Path
7
+
8
+ from flowapi .config import getsecret
9
+
10
+
11
+ def test_get_secrets (monkeypatch ):
12
+ """Test getting a secret from the special /run/secrets directory."""
13
+ the_secret = "Shhhh"
14
+ the_secret_name = "SECRET"
15
+ open_mock = unittest .mock .mock_open (read_data = the_secret )
16
+ monkeypatch .setattr ("builtins.open" , open_mock )
17
+ secret = getsecret (the_secret_name , "Not the secret" )
18
+ assert the_secret == secret
19
+ open_mock .assert_called_once_with (Path ("/run/secrets" ) / the_secret_name , "r" )
20
+
21
+
22
+ def test_get_secrets_default (monkeypatch ):
23
+ """Test getting a secret falls back to provided default with the file being there."""
24
+ the_secret = "Shhhh"
25
+ the_secret_name = "SECRET"
26
+ secret = getsecret (the_secret_name , the_secret )
27
+ assert the_secret == secret
You can’t perform that action at this time.
0 commit comments