|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | +# |
| 20 | + |
| 21 | +set -e -x |
| 22 | + |
| 23 | +export PULSAR_EXTRA_OPTS=-Dpulsar.auth.basic.conf=test-conf/.htpasswd |
| 24 | + |
| 25 | +# Generate secret key and token |
| 26 | +mkdir -p data/tokens |
| 27 | +bin/pulsar tokens create-secret-key --output data/tokens/secret.key |
| 28 | + |
| 29 | +bin/pulsar tokens create \ |
| 30 | + --subject token-principal \ |
| 31 | + --secret-key file:///pulsar/data/tokens/secret.key \ |
| 32 | + > /pulsar/data/tokens/token.txt |
| 33 | + |
| 34 | +export PULSAR_STANDALONE_CONF=test-conf/standalone-ssl-mim.conf |
| 35 | +export PULSAR_PID_DIR=/tmp |
| 36 | +bin/pulsar-daemon start standalone \ |
| 37 | + --no-functions-worker --no-stream-storage \ |
| 38 | + --bookkeeper-dir data/bookkeeper |
| 39 | + |
| 40 | +echo "-- Wait for Pulsar service to be ready" |
| 41 | +until curl http://localhost:8081/metrics > /dev/null 2>&1 ; do sleep 1; done |
| 42 | + |
| 43 | +echo "-- Pulsar service is ready -- Configure permissions" |
| 44 | + |
| 45 | +export PULSAR_CLIENT_CONF=test-conf/client-ssl-mim.conf |
| 46 | + |
| 47 | +# Create "standalone" cluster if it does not exist |
| 48 | +bin/pulsar-admin clusters list | grep -q '^standalone$' || |
| 49 | + bin/pulsar-admin clusters create \ |
| 50 | + standalone \ |
| 51 | + --url http://localhost:8081/ \ |
| 52 | + --url-secure https://localhost:8444/ \ |
| 53 | + --broker-url pulsar://localhost:6652/ \ |
| 54 | + --broker-url-secure pulsar+ssl://localhost:6653/ |
| 55 | + |
| 56 | +# Create "private" tenant |
| 57 | +bin/pulsar-admin tenants create private -r "" -c "standalone" |
| 58 | + |
| 59 | +# Create "private/auth" with required authentication |
| 60 | +bin/pulsar-admin namespaces create private/auth --clusters standalone |
| 61 | + |
| 62 | +bin/pulsar-admin namespaces grant-permission private/auth \ |
| 63 | + --actions produce,consume \ |
| 64 | + --role "token-principal" |
| 65 | + |
| 66 | +echo "-- Ready to start tests" |
0 commit comments