Fork of github.com/did-method-plc/did-method-plc
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add tests for long and non-b58 verificationMethod keys

+21 -6
+21 -6
packages/server/tests/server.test.ts
··· 113 113 await expect(promise).rejects.toThrow(PlcClientError) 114 114 }) 115 115 116 - it('allows *service* key types that we do not explicitly support', async () => { 116 + it('allows *verificationMethod* key types that we do not explicitly support', async () => { 117 117 // an ed25519 key, which we don't explicitly support 118 118 const newSigningKey = 119 119 'did:key:z6MkjwbBXZnFqL8su24wGL2Fdjti6GSLv9SWdYGswfazUPm9' ··· 138 138 }) 139 139 }) 140 140 141 - it('does not allow syntactically invalid service keys', async () => { 142 - const promise = client.updateAtprotoKey( 141 + it('does not allow syntactically invalid verificationMethod keys', async () => { 142 + const promise1 = client.updateAtprotoKey( 143 + did2, 144 + rotationKey3, 145 + 'did:key:BJV2WY5DJMJQXGZJANFZSAYLXMVZW63LFEEQFY3ZP', // not b58 (b32!) 146 + ) 147 + await expect(promise1).rejects.toThrow(PlcClientError) 148 + const promise2 = client.updateAtprotoKey( 143 149 did2, 144 150 rotationKey3, 145 151 'did:banana', // a malformed did:key 146 152 ) 147 - await expect(promise).rejects.toThrow(PlcClientError) 148 - const promise2 = client.updateAtprotoKey( 153 + await expect(promise2).rejects.toThrow(PlcClientError) 154 + const promise3 = client.updateAtprotoKey( 149 155 did2, 150 156 rotationKey3, 151 157 'blah', // an even more malformed did:key 152 158 ) 153 - await expect(promise2).rejects.toThrow(PlcClientError) 159 + await expect(promise3).rejects.toThrow(PlcClientError) 160 + }) 161 + 162 + it('does not allow unreasonably long verificationMethod keys', async () => { 163 + const promise = client.updateAtprotoKey( 164 + did2, 165 + rotationKey3, 166 + 'did:key:z41vu8qtWtp8XRJ9Te5QhkyzU9ByBbiw7bZHKXDjZ8iYorixqZQmEZpxgVSteYirYWMBjqQuEbMYTDsCzXXCAanCSH2xG2cwpbCWGZ2coY2PnhbrDVo7QghsAHpm2X5zsRRwDLyUcm9MTNQAZuRs2B22ygQw3UwkKLA7PZ9ZQ9wMHppmkoaBapmUGaxRNjp1Mt4zxrm9RbEx8FiK3ANBL1fsjggNqvkKpbj6MjntRScPQnJCes9Vt1cFe3iwNP7Ya9RfbaKsVi1eothvSBcbWoouHActGeakHgqFLj1JpbkP7PL3hGGSWLQbXxzmdrfzBCYAtiUxGRvpf3JiaNA2WYbJTh58bzx', 167 + ) 168 + await expect(promise).rejects.toThrow(PlcClientError) 154 169 }) 155 170 156 171 it('retrieves the operation log', async () => {