Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 69 additions & 38 deletions DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This document provides a complete walkthrough of all flexo-cli-client features.

## Known Issues

- **JSON-LD/RDFXML format pull** (`DEMO.md:160,163,449-453`): The layer1-service does not properly honor the Accept header for different RDF formats. Pulling with `--format jsonld` or `--format rdfxml` will fail because the server always returns Turtle format.
- **Merge/diff operations** (`DEMO.md:248,390-394`): The merge command with `--no-commit` and subsequent diff creation fails with "Not implemented (formulae, graph literals)" due to a TriG parsing issue in the layer1-service.

## Prerequisites

```bash
Expand Down Expand Up @@ -42,15 +47,22 @@ This will:
2. Create org: localorg
3. Create repo: localrepo
(master branch is created automatically by the service)
Starting Docker services...
Starting Fuseki (quad-store-server)...
Using docker-compose file: /tmp/...
Docker services started
Waiting for services to be ready...
Services are ready
Generating cluster configuration...
Cluster configuration generated
Fuseki started
Waiting for Fuseki to be ready...
Fuseki is ready
Loading cluster configuration into Fuseki...
Cluster configuration loaded
Cluster configuration loaded into Fuseki
Ensuring Fuseki index is ready...
Fuseki index is ready
Starting layer1-service...
layer1-service started
Waiting for layer1-service to be ready...
layer1-service is ready
Verifying layer1-service health...
layer1-service is ready
Creating organization 'localorg'...
Organization created
Creating repository 'localrepo'...
Expand All @@ -61,22 +73,9 @@ Configuration updated in ~/.flexo/config with:
default.repo=localrepo
```

### 1.2 Verify Configuration

Note: Add a local remote manually for remote operations:
```bash
cat ~/.flexo/config
```

Expected:
```properties
# Flexo CLI Configuration
mms.url=http://localhost:8080
local.mode=true
local.user=root
local.jwtSecret=<auto-generated-base64-secret>
default.org=localorg
default.repo=localrepo
default.branch=master
./build/install/flexo/bin/flexo remote add local http://localhost:8080 --set-default
```

---
Expand Down Expand Up @@ -107,7 +106,7 @@ master ... ...
./build/install/flexo/bin/flexo --org localorg --repo localrepo branch --create feature-xyz

# Create branch from specific source
./build/install/flexo/bin/flexo branch --create feature-abc --from develop
./build/install/flexo/bin/flexo branch --create feature-abc --from master
```

### 2.3 Verify Branch Creation
Expand Down Expand Up @@ -147,10 +146,10 @@ feature-abc ... ...
# Pull to Turtle file (default format)
./build/install/flexo/bin/flexo pull --branch master --output model.ttl

# Pull to JSON-LD
# Pull to JSON-LD [Currently broken - server returns Turtle instead of JSON-LD]
./build/install/flexo/bin/flexo pull --branch master --format jsonld --output model.jsonld

# Pull to RDF/XML
# Pull to RDF/XML [Currently broken - server returns Turtle instead of RDF/XML]
./build/install/flexo/bin/flexo pull --branch feature-xyz --format rdfxml --output model.rdf

# Pull from specific remote
Expand Down Expand Up @@ -202,7 +201,24 @@ EOF
--input /tmp/test-model.ttl
```

### 4.3 Push Different RDF Formats
### 4.3 Verify Push

```bash
# Pull from default branch to verify the push
./build/install/flexo/bin/flexo pull --branch master

# Pull from feature branch to verify
./build/install/flexo/bin/flexo pull --branch feature-xyz
```

Expected output:
```
Pulling from localorg/localrepo/master...
Fetched model with 5 statements
[RDF/Turtle output showing the pushed model]
```

### 4.4 Push Different RDF Formats

```bash
# Push JSON-LD
Expand All @@ -216,13 +232,13 @@ EOF
--input model.rdf
```

### 4.4 Push from stdin
### 4.5 Push from stdin

```bash
cat /tmp/test-model.ttl | ./build/install/flexo/bin/flexo push --message "Push from stdin"
```

### 4.5 Alternative Syntax
### 4.6 Alternative Syntax

```bash
./build/install/flexo/bin/flexo push master --message "Update master" --input /tmp/test-model.ttl
Expand All @@ -235,11 +251,11 @@ cat /tmp/test-model.ttl | ./build/install/flexo/bin/flexo push --message "Push f
### 5.1 View Diff Between Branches

```bash
# Create diff without committing
# Create diff without committing [Currently broken - TriG parsing error]
./build/install/flexo/bin/flexo merge --source feature-xyz --target master --no-commit

# Alternative syntax
./build/install/flexo/bin/flexo merge feature-xyz
# Alternative syntax (requires --source flag)
./build/install/flexo/bin/flexo merge --source feature-xyz
```

Expected output:
Expand All @@ -248,6 +264,8 @@ Diff between feature-xyz and master:
[Diff output from server]
```

> **Known Issue**: The merge diff feature currently fails with "Not implemented (formulae, graph literals)" due to TriG parsing in the layer1-service.

### 5.2 Merge Changes

```bash
Expand All @@ -270,17 +288,17 @@ Diff between feature-xyz and master:
./build/install/flexo/bin/flexo remote list
```

Expected:
Expected (after adding local remote):
```
origin http://localhost:8080 (local mode: true)
local * http://localhost:8080
```

### 6.2 Add Remote

```bash
# Add local remote with local mode
./build/install/flexo/bin/flexo remote add local http://localhost:8080 \
--local-mode true \
--local-mode \
--local-user root \
--set-default

Expand All @@ -296,10 +314,17 @@ origin http://localhost:8080 (local mode: true)
### 6.3 Show Remote Details

```bash
./build/install/flexo/bin/flexo remote show origin
./build/install/flexo/bin/flexo remote show local
./build/install/flexo/bin/flexo remote show production
```

Expected:
```
Remote: local (default)
URL: http://localhost:8080
Local Mode: enabled
```

### 6.4 Update Remote URL

```bash
Expand Down Expand Up @@ -371,16 +396,18 @@ EOF
### 7.3 Merge Feature into Master

```bash
# 1. View diff before merging
# 1. View diff before merging [Currently broken - TriG parsing error]
./build/install/flexo/bin/flexo merge --source feature-login --target master --no-commit

# 2. Merge (if diff looks correct)
# 2. Merge (if diff looks correct) [Currently broken - TriG parsing error]
./build/install/flexo/bin/flexo merge --source feature-login --target master

# 3. Verify master has the changes
./build/install/flexo/bin/flexo pull --branch master --output master-updated.ttl
```

> **Known Issue**: Merge operations are currently broken due to layer1-service TriG parsing.

---

## Phase 8: Configuration Management
Expand Down Expand Up @@ -425,12 +452,16 @@ export FLEXO_DEFAULT_REPO=localrepo
### 9.2 Format Conversion Demo

```bash
# Pull in different formats
# Pull in Turtle format (default and working)
./build/install/flexo/bin/flexo pull --branch master --format turtle --output model.ttl

# Pull in JSON-LD format [Currently broken - server returns Turtle]
./build/install/flexo/bin/flexo pull --branch master --format jsonld --output model.jsonld

# Pull in RDF/XML format [Currently broken - server returns Turtle]
./build/install/flexo/bin/flexo pull --branch master --format rdfxml --output model.rdf

# Push different formats
# Push different formats (these work as input formats)
./build/install/flexo/bin/flexo push --format jsonld \
--message "Push JSON-LD" \
--input model.jsonld
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ tasks.test {
}

tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
dependsOn tasks.test
reports {
xml.required.set(true)
html.required.set(true)
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/main/java/org/openmbee/flexo/cli/FlexoCLI.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openmbee.flexo.cli;

import org.openmbee.flexo.cli.commands.BranchCommand;
import org.openmbee.flexo.cli.commands.CommandExecutionException;
import org.openmbee.flexo.cli.commands.InitCommand;
import org.openmbee.flexo.cli.commands.MergeCommand;
import org.openmbee.flexo.cli.commands.PullCommand;
Expand Down Expand Up @@ -93,8 +94,8 @@ public static void main(String[] args) {
int exitCode;
try {
exitCode = commandLine.execute(args);
} catch (BaseCommand.CommandException e) {
// CommandException already logged error message
} catch (CommandExecutionException e) {
// CommandExecutionException already logged error message
exitCode = e.getExitCode();
} catch (Exception e) {
ConsoleUtil.error("Unexpected error: " + e.getMessage());
Expand Down Expand Up @@ -126,6 +127,10 @@ public static FlexoConfig getConfig() {
return config;
}

public static void setConfig(FlexoConfig testConfig) {
config = testConfig;
}

public String getOrgId() {
return orgId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,6 @@ private void validateJwtSecret(String secret) {
if (secret.length() < 32) {
logger.warn("SECURITY WARNING: local.jwtSecret is too short (minimum 32 characters recommended)");
}

String[] weakSecrets = {
"devsecret",
"secret",
"password",
"changeme",
"test",
"dev",
"local"
};

String lowerSecret = secret.toLowerCase();
boolean isGenerated = secret.length() >= 64 && secret.matches("[A-Za-z0-9+/=]+");
if (isGenerated) {
return;
}

for (String weak : weakSecrets) {
if (lowerSecret.contains(weak)) {
logger.warn("SECURITY WARNING: local.jwtSecret appears to contain weak or default values");
logger.warn("Please use a strong, randomly generated secret for production use");
break;
}
}
}

/**
Expand Down
Loading