Skip to content

Commit

Permalink
fix: remove identityVerify document and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Nov 21, 2024
1 parent a5fefa6 commit 6440612
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 234 deletions.
70 changes: 0 additions & 70 deletions packages/wallet-contract/schema/v1/wallet-contract-documents.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,75 +51,5 @@
"$createdAt"
],
"additionalProperties": false
},
"identityVerify": {
"documentsMutable": true,
"canBeDeleted": true,
"type": "object",
"properties": {
"normalizedLabel": {
"position": 0,
"type": "string",
"pattern": "^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-]{0,61}[a-hj-km-np-z0-9]$",
"maxLength": 63,
"description": "Domain label converted to lowercase for case-insensitive uniqueness validation. \"o\", \"i\" and \"l\" replaced with \"0\" and \"1\" to mitigate homograph attack. e.g. 'b0b'",
"$comment": "Must match a domain document to provide further information. Must be equal to the label in lowercase. \"o\", \"i\" and \"l\" must be replaced with \"0\" and \"1\"."
},
"normalizedParentDomainName": {
"type": "string",
"pattern": "^$|^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-\\.]{0,61}[a-hj-km-np-z0-9]$",
"minLength": 0,
"maxLength": 63,
"position": 1,
"description": "A parent domain name in lowercase for case-insensitive uniqueness validation. \"o\", \"i\" and \"l\" replaced with \"0\" and \"1\" to mitigate homograph attack. e.g. 'dash'",
"$comment": "Must either be equal to an existing domain or empty to create a top level domain. \"o\", \"i\" and \"l\" must be replaced with \"0\" and \"1\". Only the data contract owner can create top level domains."
},
"url": {
"position": 2,
"type": "string",
"description": "The identity verification URL to be stored.",
"maxLength": 128,
"pattern": "^https?://.*",
"format": "uri"
}
},
"indices": [
{
"name": "ownerId",
"properties": [
{
"$ownerId": "asc"
}
]
},
{
"name": "ownerId_NormDomainName_NormLabel",
"properties": [
{
"$ownerId": "asc"
},
{
"normalizedParentDomainName": "asc"
},
{
"normalizedLabel": "asc"
}
]
},
{
"name": "uniqueUsernameIndex",
"properties": [
{
"normalizedLabel": "asc"
}
]
}
],
"required": [
"url",
"normalizedLabel",
"normalizedParentDomainName"
],
"additionalProperties": false
}
}
164 changes: 0 additions & 164 deletions packages/wallet-contract/test/unit/walletContract.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,169 +167,5 @@ describe('Wallet Contract', () => {
.true();
});
});

describe('verifyIdentity', () => {
let rawIdentityVerifyDocument;

beforeEach(async () => {
rawIdentityVerifyDocument = {
normalizedLabel: 'wa11et', // lower case and base58 chars only
normalizedParentDomainName: 'dash',
url: "https://dash.org"
};
});

describe('normalizedLabel', () => {
it('should be defined', async () => {
delete rawIdentityVerifyDocument.normalizedLabel;

const document = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);
const validationResult = document.validate(dpp.protocolVersion);
const error = expectJsonSchemaError(validationResult);

expect(error.keyword)
.to
.equal('required');
expect(error.params.missingProperty)
.to
.equal('normalizedLabel');
});

it('should follow pattern', async () => {
rawIdentityVerifyDocument.normalizedLabel = 'InValiD label';

const document = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);
const validationResult = document.validate(dpp.protocolVersion);
const error = expectJsonSchemaError(validationResult);

expect(error.keyword)
.to
.equal('pattern');
expect(error.instancePath)
.to
.equal('/normalizedLabel');
});

it('should be less than 63 chars', async () => {
rawIdentityVerifyDocument.normalizedLabel = 'a'.repeat(64);

const document = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);
const validationResult = document.validate(dpp.protocolVersion);
const error = expectJsonSchemaError(validationResult, 2);

expect(error.keyword)
.to
.equal('pattern');
expect(error.instancePath)
.to
.equal('/normalizedLabel');
});
});

describe('normalizedParentDomainName', () => {
it('should be defined', async () => {
delete rawIdentityVerifyDocument.normalizedParentDomainName;

const document = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);
const validationResult = document.validate(dpp.protocolVersion);
const error = expectJsonSchemaError(validationResult);

expect(error.keyword)
.to
.equal('required');
expect(error.params.missingProperty)
.to
.equal('normalizedParentDomainName');
});

it('should be less than 190 chars', async () => {
rawIdentityVerifyDocument.normalizedParentDomainName = 'a'.repeat(191);

const document = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);
const validationResult = document.validate(dpp.protocolVersion);
const error = expectJsonSchemaError(validationResult, 2);

expect(error.keyword)
.to
.equal('pattern');
expect(error.instancePath)
.to
.equal('/normalizedParentDomainName');
});

it('should follow pattern', async () => {
rawIdentityVerifyDocument.normalizedParentDomainName = '&'.repeat(50);

const document = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);
const validationResult = document.validate(dpp.protocolVersion);
const error = expectJsonSchemaError(validationResult);

expect(error.keyword)
.to
.equal('pattern');
expect(error.instancePath)
.to
.equal('/normalizedParentDomainName');
});
});

describe('url', () => {
it('should be defined', async () => {
delete rawIdentityVerifyDocument.url;

const document = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);
const validationResult = document.validate(dpp.protocolVersion);
const error = expectJsonSchemaError(validationResult);

expect(error.keyword)
.to
.equal('required');
expect(error.params.missingProperty)
.to
.equal('url');
});

it('should be less than 128 chars', async () => {
rawIdentityVerifyDocument.url = 'a'.repeat(129);

const document = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);
const validationResult = document.validate(dpp.protocolVersion);
const error = expectJsonSchemaError(validationResult, 2);

expect(error.keyword)
.to
.equal('pattern');
expect(error.instancePath)
.to
.equal('/url');
});

it('should follow pattern', async () => {
rawIdentityVerifyDocument.url = '&'.repeat(50);

const document = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);
const validationResult = document.validate(dpp.protocolVersion);
const error = expectJsonSchemaError(validationResult);

expect(error.keyword)
.to
.equal('pattern');
expect(error.instancePath)
.to
.equal('/url');
});
});

it('should be valid', async () => {
const domain = dpp.document.create(dataContract, identityId, 'domain', rawIdentityVerifyDocument);

const result = await domain.validate(dpp.protocolVersion);

expect(result.isValid())
.to
.be
.true();
});
});
});
});

0 comments on commit 6440612

Please sign in to comment.