package cz.moneta.test.system.nasdb;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.dsl.util.data.client.NonClient;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.auth.AuthSupport;

import static cz.moneta.test.dsl.util.credentials.Keys.ufo.banka.banker;

@TestScenario(name = "creates a client and promotes them to an internal user respectively")
public class InsertUser {

    @TestCase(name = "creates a client and promotes them to an internal user respectively")
    public void insert_user(Harness harness) {
        NonClient person = harness.data().newNonClient();
        BankaTasks withBanka = harness.tasks().ufo().banka();
        String bankerUsername = AuthSupport.getCredentials(banker, harness).getUsername();

        harness.withUfo()
                .openLoginPage()
                .then(withBanka.login().asBanker())
                .then(withBanka.login().turnSignpadOff())
                .then(withBanka.newClient().create(person, bankerUsername));

        harness.tasks().nasDb().insertUser(person);

        //TODO assert SSO created
    }
}
