mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
tests/taler: create exchange credentials at runtime
Basic auth is deprecated, so exchange credentials must be set at runtime
because it requires a token from the bank.
(cherry picked from commit 21ad6f743c
)
This commit is contained in:
parent
27fdb64e86
commit
d5fb6d6da9
4 changed files with 23 additions and 7 deletions
|
@ -55,7 +55,12 @@ rec {
|
||||||
settings = {
|
settings = {
|
||||||
taler.CURRENCY = CURRENCY;
|
taler.CURRENCY = CURRENCY;
|
||||||
};
|
};
|
||||||
includes = [ ../conf/taler-accounts.conf ];
|
includes = [
|
||||||
|
../conf/taler-accounts.conf
|
||||||
|
# The exchange requires a token from the bank, so its credentials
|
||||||
|
# need to be set at runtime
|
||||||
|
"/etc/taler/secrets/exchange-account.secret.conf"
|
||||||
|
];
|
||||||
exchange = {
|
exchange = {
|
||||||
enable = true;
|
enable = true;
|
||||||
debug = true;
|
debug = true;
|
||||||
|
|
|
@ -83,6 +83,17 @@ in
|
||||||
return json.loads(response)["access_token"]
|
return json.loads(response)["access_token"]
|
||||||
|
|
||||||
|
|
||||||
|
# Basic auth is deprecated, so exchange credentials must be set at
|
||||||
|
# runtime because it requires a token from the bank.
|
||||||
|
def create_exchange_auth(token: str):
|
||||||
|
template = f"""
|
||||||
|
[exchange-accountcredentials-test]
|
||||||
|
WIRE_GATEWAY_URL = http://bank:8082/accounts/exchange/taler-wire-gateway/
|
||||||
|
WIRE_GATEWAY_AUTH_METHOD = BEARER
|
||||||
|
TOKEN = "{token}"
|
||||||
|
"""
|
||||||
|
return "\n".join([line.strip() for line in template.splitlines()])
|
||||||
|
|
||||||
def verify_balance(balanceWanted: str):
|
def verify_balance(balanceWanted: str):
|
||||||
"""Compare Taler CLI wallet balance with expected amount"""
|
"""Compare Taler CLI wallet balance with expected amount"""
|
||||||
balance = wallet_cli("balance --json")
|
balance = wallet_cli("balance --json")
|
||||||
|
|
|
@ -2,9 +2,3 @@
|
||||||
PAYTO_URI = payto://x-taler-bank/bank:8082/exchange?receiver-name=Exchange
|
PAYTO_URI = payto://x-taler-bank/bank:8082/exchange?receiver-name=Exchange
|
||||||
ENABLE_DEBIT = YES
|
ENABLE_DEBIT = YES
|
||||||
ENABLE_CREDIT = YES
|
ENABLE_CREDIT = YES
|
||||||
|
|
||||||
[exchange-accountcredentials-test]
|
|
||||||
WIRE_GATEWAY_URL = http://bank:8082/accounts/exchange/taler-wire-gateway/
|
|
||||||
WIRE_GATEWAY_AUTH_METHOD = BASIC
|
|
||||||
USERNAME = exchange
|
|
||||||
PASSWORD = exchange
|
|
||||||
|
|
|
@ -76,11 +76,17 @@ import ../../make-test-python.nix (
|
||||||
|
|
||||||
|
|
||||||
exchange.start()
|
exchange.start()
|
||||||
|
|
||||||
|
# exchange credentials must be set at runtime because it requires a token from the bank
|
||||||
|
exchange.succeed("mkdir -p /etc/taler/secrets/")
|
||||||
|
exchange.succeed("touch /etc/taler/secrets/exchange-account.secret.conf")
|
||||||
|
|
||||||
exchange.wait_for_open_port(8081)
|
exchange.wait_for_open_port(8081)
|
||||||
|
|
||||||
# Create access token for exchange
|
# Create access token for exchange
|
||||||
accessTokenExchange = create_token(exchange, "exchange", "exchange")
|
accessTokenExchange = create_token(exchange, "exchange", "exchange")
|
||||||
|
|
||||||
|
exchange.succeed(f'echo "{create_exchange_auth(accessTokenExchange)}" > /etc/taler/secrets/exchange-account.secret.conf')
|
||||||
|
|
||||||
with subtest("Set up exchange"):
|
with subtest("Set up exchange"):
|
||||||
exchange.wait_until_succeeds("taler-exchange-offline download sign upload")
|
exchange.wait_until_succeeds("taler-exchange-offline download sign upload")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue