mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
1e088c0af2
Summary: * Added intermediate (de)serializers for config types, so that we generate full Identity objects at config load time * Implement FromStr for Identity * Compare configured identities to presented identities in ratelimit middleware in order to decide whether or not to apply the limit Reviewed By: krallin Differential Revision: D20139308 fbshipit-source-id: 340c300db549575eb6d06efcbe437c0b1db4927b
52 lines
1.6 KiB
Raku
52 lines
1.6 KiB
Raku
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License found in the LICENSE file in the root
|
|
# directory of this source tree.
|
|
|
|
$ . "${TEST_FIXTURES}/library.sh"
|
|
|
|
# Create a repository
|
|
$ setup_mononoke_config
|
|
$ REPOID=1 setup_mononoke_repo_config repo1
|
|
$ LIVE_CONFIG="${TESTTMP}/live.json"
|
|
$ cat > "$LIVE_CONFIG" << EOF
|
|
> {
|
|
> "track_bytes_sent": true,
|
|
> "enable_consistent_routing": false,
|
|
> "disable_hostname_logging": false,
|
|
> "throttle_limits": [
|
|
> {
|
|
> "counter": "mononoke.lfs.download.size_bytes_sent.sum.5",
|
|
> "limit": 10,
|
|
> "sleep_ms": 1000,
|
|
> "max_jitter_ms": 100,
|
|
> "client_identities": [
|
|
> "USER:myusername0"
|
|
> ]
|
|
> }
|
|
> ],
|
|
> "acl_check": true,
|
|
> "enforce_acl_check": false
|
|
> }
|
|
> EOF
|
|
|
|
# Start an LFS server
|
|
$ lfs_log="$TESTTMP/lfs.log"
|
|
$ lfs_uri="$(lfs_server --tls --log "$lfs_log" --live-config "file:${LIVE_CONFIG}")/repo1"
|
|
|
|
# Upload data
|
|
$ yes A 2>/dev/null | head -c 2KiB | ssldebuglfssend "$lfs_uri"
|
|
ab02c2a1923c8eb11cb3ddab70320746d71d32ad63f255698dc67c3295757746 2048
|
|
|
|
# Download the file. Note the blake2 is used here.
|
|
$ sslcurl -s -o /dev/null -w "%{http_code}\n" "${lfs_uri}/download/d28548bc21aabf04d143886d717d72375e3deecd0dafb3d110676b70a192cb5d"
|
|
200
|
|
|
|
# Give stats aggregation time to complete
|
|
$ sleep 2
|
|
|
|
# Next request should be throttled
|
|
$ sslcurl -s -o /dev/null -w "%{http_code}\n" "${lfs_uri}/download/d28548bc21aabf04d143886d717d72375e3deecd0dafb3d110676b70a192cb5d"
|
|
429
|