зеркало из https://github.com/microsoft/etcd3.git
fix: skip test in older version that lacks permission check
This commit is contained in:
Родитель
b5306c9dd7
Коммит
0ac0697373
|
@ -21,3 +21,5 @@ jobs:
|
|||
- run: npm ci
|
||||
- run: npm run build:ts
|
||||
- run: npm test
|
||||
env:
|
||||
ETCD_VERSION: ${{ matrix.etcd-version }}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
Thank you to [@pauliusuza](https://github.com/pauliusuza) for his help updating everything
|
||||
|
||||
- **feat**: add `SingleRangeBuilder.exists()` that returns if the given key exists
|
||||
- **fix**: errors when creating watchers not being handled correctly (see [114](https://github.com/microsoft/etcd3/issues/114))
|
||||
|
||||
## 0.2.13 2019-07-03
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ const tlsKey = fs.readFileSync(`${rootPath}/src/test/certs/private/etcd0.localho
|
|||
const etcdSourceAddress = process.env.ETCD_ADDR || '127.0.0.1:2379';
|
||||
const [etcdSourceHost, etcdSourcePort] = etcdSourceAddress.split(':');
|
||||
|
||||
export const etcdVersion = process.env.ETCD_VERSION || '3.3.9';
|
||||
|
||||
/**
|
||||
* Proxy is a TCP proxy for etcd, used so that we can simulate network failures
|
||||
* and disruptions in a cross-platform manner (i.e no reliance on tcpkill
|
||||
|
@ -261,3 +263,12 @@ export async function removeAuth(client: Etcd3) {
|
|||
await wipeAll(client.getUsers());
|
||||
await wipeAll(client.getRoles());
|
||||
}
|
||||
|
||||
const compareVersion = (version: string) => {
|
||||
const aParts = etcdVersion.split('.').map(Number);
|
||||
const bParts = version.split('.').map(Number);
|
||||
return aParts.map((a, i) => a - bParts[i]).find(cmp => cmp !== 0) ?? 0;
|
||||
};
|
||||
|
||||
export const isAtLeastVersion = (version: string) => compareVersion(version) >= 0;
|
||||
export const atAtMostVersion = (version: string) => compareVersion(version) <= 0;
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
tearDownTestClient,
|
||||
setupAuth,
|
||||
removeAuth,
|
||||
isAtLeastVersion,
|
||||
} from './util';
|
||||
import { EtcdPermissionDeniedError } from '../errors';
|
||||
|
||||
|
@ -127,20 +128,22 @@ describe('watch()', () => {
|
|||
beforeEach(() => setupAuth(client));
|
||||
afterEach(() => removeAuth(client));
|
||||
|
||||
it('is fixed', async () => {
|
||||
const authedClient = new Etcd3(
|
||||
getOptions({
|
||||
auth: {
|
||||
username: 'connor',
|
||||
password: 'password',
|
||||
},
|
||||
}),
|
||||
);
|
||||
if (isAtLeastVersion('3.2.0')) {
|
||||
it('is fixed', async () => {
|
||||
const authedClient = new Etcd3(
|
||||
getOptions({
|
||||
auth: {
|
||||
username: 'connor',
|
||||
password: 'password',
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(authedClient.watch().key('outside of range').create()).to.be.rejectedWith(
|
||||
EtcdPermissionDeniedError,
|
||||
);
|
||||
});
|
||||
await expect(authedClient.watch().key('outside of range').create()).to.be.rejectedWith(
|
||||
EtcdPermissionDeniedError,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче