Skip to content

A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.

1.5 KB
Raw Blame
package opensuite.ui;

import opensuite.core.Settings;
import opensuite.testkit.Expect;
import opensuite.testkit.Harness;

import java.io.File;

/** Settings > Project > Automatic backup: when a backup is due and where it goes. */
public final class AutoBackupTest {

    public void run() {
        Harness.suite("automatic backup");

        Harness.test("a backup is due only for a disk project, when switched on, after the interval", () -> {
            Settings s = new Settings();
            long minute = 60_000L;
            try {
                Expect.isTrue(!AutoBackup.due(s, true, 0, 100 * minute), "off by default");
                s.setBool(AutoBackup.AUTO, true);
                s.setInt(AutoBackup.MINUTES, 10);
                Expect.isTrue(!AutoBackup.due(s, false, 0, 100 * minute), "a temporary project has nothing to back up");
                Expect.isTrue(!AutoBackup.due(s, true, 0, 9 * minute), "not yet");
                Expect.isTrue(AutoBackup.due(s, true, 0, 10 * minute), "after the interval");
                s.setInt(AutoBackup.MINUTES, 0);
                Expect.isTrue(!AutoBackup.due(s, true, 0, minute / 2) && AutoBackup.due(s, true, 0, minute), "never more often than each minute");
            } finally { s.remove(AutoBackup.AUTO); s.remove(AutoBackup.MINUTES); }
        });

        Harness.test("the backup sits beside the project with .bak added", () -> {
            File f = AutoBackup.fileFor(new File("/work/acme.osuite"));
            Expect.isTrue(f.equals(new File("/work/acme.osuite.bak")), f.getPath());
        });
    }
}