Missing sha1 error demoted to a warning

This commit is contained in:
Kris De Volder
2017-07-21 11:47:40 -07:00
parent 47d401a973
commit dc07bbf32a
3 changed files with 30 additions and 4 deletions

View File

@@ -10,7 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.bosh;
import static org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems.MISSING_PROPERTY;
import static org.springframework.ide.vscode.bosh.BoshSchemaProblems.MISSING_SHA1_PROPERTY;
import static org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems.problem;
import org.springframework.ide.vscode.commons.languageserver.reconcile.IProblemCollector;
@@ -24,7 +24,7 @@ import org.yaml.snakeyaml.nodes.NodeTuple;
public class BoshConstraints {
public static final Constraint SHA1_REQUIRED_FOR_HTTP_URL = new Constraint() {
@Override
public void verify(DynamicSchemaContext dc, Node parent, Node node, YType type, IProblemCollector problems) {
NodeTuple urlProp = NodeUtil.getPropertyTuple(node, "url");
@@ -33,7 +33,7 @@ public class BoshConstraints {
if (url!=null && url.startsWith("http")) {
Node sha1 = NodeUtil.getProperty(node, "sha1");
if (sha1==null) {
problems.accept(problem(MISSING_PROPERTY, "'sha1' is required when the 'url' is http(s)", urlProp.getKeyNode()));
problems.accept(problem(MISSING_SHA1_PROPERTY, "'sha1' is recommended when the 'url' is http(s)", urlProp.getKeyNode()));
}
}
}

View File

@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.bosh;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemType;
import org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems;
public class BoshSchemaProblems {
public static final ProblemType MISSING_SHA1_PROPERTY = YamlSchemaProblems.problemType("MISSING_SHA1_PROPERTY", ProblemSeverity.WARNING);
}

View File

@@ -18,6 +18,8 @@ import java.io.IOException;
import java.util.concurrent.TimeoutException;
import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -276,10 +278,13 @@ public class BoshEditorTest {
"#x"
);
editor.assertProblems(
"url|'sha1' is required when the 'url' is http(s)",
"url|'sha1' is recommended when the 'url' is http(s)",
"proto|Url scheme must be one of [http, https, file]",
"x|are required"
);
Diagnostic missingSha1Problem = editor.assertProblem("url");
assertContains("'sha1' is recommended", missingSha1Problem.getMessage());
assertEquals(DiagnosticSeverity.Warning, missingSha1Problem.getSeverity());
}
@Test public void releasesBlockPropertyReconcileAndHovers() throws Exception {