Missing sha1 error demoted to a warning
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user