Search in sources :

Example 1 with AccessRestrictionType

use of com.gitblit.Constants.AccessRestrictionType in project gitblit by gitblit.

the class NewRepositoryPage method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    CompoundPropertyModel<RepositoryModel> rModel = new CompoundPropertyModel<>(repositoryModel);
    Form<RepositoryModel> form = new Form<RepositoryModel>("editForm", rModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit() {
            try {
                if (!namePanel.updateModel(repositoryModel)) {
                    return;
                }
                accessPolicyPanel.updateModel(repositoryModel);
                repositoryModel.owners = new ArrayList<String>();
                repositoryModel.owners.add(GitBlitWebSession.get().getUsername());
                // setup branch defaults
                boolean useGitFlow = addGitflowModel.getObject();
                repositoryModel.HEAD = Constants.R_MASTER;
                repositoryModel.mergeTo = Constants.MASTER;
                if (useGitFlow) {
                    // tickets normally merge to develop unless they are hotfixes
                    repositoryModel.mergeTo = Constants.DEVELOP;
                }
                repositoryModel.allowForks = app().settings().getBoolean(Keys.web.allowForking, true);
                // optionally generate an initial commit
                boolean addReadme = addReadmeModel.getObject();
                String gitignore = null;
                boolean addGitignore = addGitignoreModel.getObject();
                if (addGitignore) {
                    gitignore = gitignoreModel.getObject();
                    if (StringUtils.isEmpty(gitignore)) {
                        throw new GitBlitException(getString("gb.pleaseSelectGitIgnore"));
                    }
                }
                // init the repository
                app().gitblit().updateRepositoryModel(repositoryModel.name, repositoryModel, true);
                // optionally create an initial commit
                initialCommit(repositoryModel, addReadme, gitignore, useGitFlow);
            } catch (GitBlitException e) {
                error(e.getMessage());
                return;
            }
            setRedirect(true);
            setResponsePage(SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryModel.name));
        }
    };
    // do not let the browser pre-populate these fields
    form.add(new SimpleAttributeModifier("autocomplete", "off"));
    namePanel = new RepositoryNamePanel("namePanel", repositoryModel);
    form.add(namePanel);
    // prepare the default access controls
    AccessRestrictionType defaultRestriction = AccessRestrictionType.fromName(app().settings().getString(Keys.git.defaultAccessRestriction, AccessRestrictionType.PUSH.name()));
    if (AccessRestrictionType.NONE == defaultRestriction) {
        defaultRestriction = AccessRestrictionType.PUSH;
    }
    AuthorizationControl defaultControl = AuthorizationControl.fromName(app().settings().getString(Keys.git.defaultAuthorizationControl, AuthorizationControl.NAMED.name()));
    if (AuthorizationControl.AUTHENTICATED == defaultControl) {
        defaultRestriction = AccessRestrictionType.PUSH;
    }
    repositoryModel.authorizationControl = defaultControl;
    repositoryModel.accessRestriction = defaultRestriction;
    accessPolicyPanel = new AccessPolicyPanel("accessPolicyPanel", repositoryModel);
    form.add(accessPolicyPanel);
    //
    // initial commit options
    //
    // add README
    addReadmeModel = Model.of(false);
    form.add(new BooleanOption("addReadme", getString("gb.initWithReadme"), getString("gb.initWithReadmeDescription"), addReadmeModel));
    // add .gitignore
    File gitignoreDir = app().runtime().getFileOrFolder(Keys.git.gitignoreFolder, "${baseFolder}/gitignore");
    File[] files = gitignoreDir.listFiles();
    if (files == null) {
        files = new File[0];
    }
    List<String> gitignores = new ArrayList<String>();
    for (File file : files) {
        if (file.isFile() && file.getName().endsWith(".gitignore")) {
            gitignores.add(StringUtils.stripFileExtension(file.getName()));
        }
    }
    Collections.sort(gitignores);
    gitignoreModel = Model.of("");
    addGitignoreModel = Model.of(false);
    form.add(new BooleanChoiceOption<String>("addGitIgnore", getString("gb.initWithGitignore"), getString("gb.initWithGitignoreDescription"), addGitignoreModel, gitignoreModel, gitignores).setVisible(gitignores.size() > 0));
    // TODO consider gitflow at creation (ticket-55)
    addGitflowModel = Model.of(false);
    form.add(new BooleanOption("addGitFlow", "Include a .gitflow file", "This will generate a config file which guides Git clients in setting up Gitflow branches.", addGitflowModel).setVisible(false));
    form.add(new Button("create"));
    add(form);
}
Also used : RepositoryNamePanel(com.gitblit.wicket.panels.RepositoryNamePanel) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) GitBlitException(com.gitblit.GitBlitException) SimpleAttributeModifier(org.apache.wicket.behavior.SimpleAttributeModifier) RepositoryModel(com.gitblit.models.RepositoryModel) BooleanChoiceOption(com.gitblit.wicket.panels.BooleanChoiceOption) Button(org.apache.wicket.markup.html.form.Button) AccessRestrictionType(com.gitblit.Constants.AccessRestrictionType) AuthorizationControl(com.gitblit.Constants.AuthorizationControl) File(java.io.File) AccessPolicyPanel(com.gitblit.wicket.panels.AccessPolicyPanel) BooleanOption(com.gitblit.wicket.panels.BooleanOption)

Example 2 with AccessRestrictionType

use of com.gitblit.Constants.AccessRestrictionType in project gitblit by gitblit.

the class AccessPolicyPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    AccessPolicy anonymousPolicy = new AccessPolicy(getString("gb.anonymousPolicy"), getString("gb.anonymousPolicyDescription"), "blank.png", AuthorizationControl.AUTHENTICATED, AccessRestrictionType.NONE);
    AccessPolicy authenticatedPushPolicy = new AccessPolicy(getString("gb.authenticatedPushPolicy"), getString("gb.authenticatedPushPolicyDescription"), "lock_go_16x16.png", AuthorizationControl.AUTHENTICATED, AccessRestrictionType.PUSH);
    AccessPolicy namedPushPolicy = new AccessPolicy(getString("gb.namedPushPolicy"), getString("gb.namedPushPolicyDescription"), "lock_go_16x16.png", AuthorizationControl.NAMED, AccessRestrictionType.PUSH);
    AccessPolicy clonePolicy = new AccessPolicy(getString("gb.clonePolicy"), getString("gb.clonePolicyDescription"), "lock_pull_16x16.png", AuthorizationControl.NAMED, AccessRestrictionType.CLONE);
    AccessPolicy viewPolicy = new AccessPolicy(getString("gb.viewPolicy"), getString("gb.viewPolicyDescription"), "shield_16x16.png", AuthorizationControl.NAMED, AccessRestrictionType.VIEW);
    List<AccessPolicy> policies = new ArrayList<AccessPolicy>();
    if (app().settings().getBoolean(Keys.git.allowAnonymousPushes, false)) {
        policies.add(anonymousPolicy);
    }
    policies.add(authenticatedPushPolicy);
    policies.add(namedPushPolicy);
    policies.add(clonePolicy);
    policies.add(viewPolicy);
    AccessRestrictionType defaultRestriction = repository.accessRestriction;
    if (defaultRestriction == null) {
        defaultRestriction = AccessRestrictionType.fromName(app().settings().getString(Keys.git.defaultAccessRestriction, AccessRestrictionType.PUSH.name()));
    }
    AuthorizationControl defaultControl = repository.authorizationControl;
    if (defaultControl == null) {
        defaultControl = AuthorizationControl.fromName(app().settings().getString(Keys.git.defaultAuthorizationControl, AuthorizationControl.NAMED.name()));
    }
    AccessPolicy defaultPolicy = namedPushPolicy;
    for (AccessPolicy policy : policies) {
        if (policy.type == defaultRestriction && policy.control == defaultControl) {
            defaultPolicy = policy;
        }
    }
    policiesGroup = new RadioGroup<>("policiesGroup", new Model<AccessPolicy>(defaultPolicy));
    ListView<AccessPolicy> policiesList = new ListView<AccessPolicy>("policies", policies) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<AccessPolicy> item) {
            AccessPolicy p = item.getModelObject();
            item.add(new Radio<AccessPolicy>("radio", item.getModel()));
            item.add(WicketUtils.newImage("image", p.image));
            item.add(new Label("name", p.name));
            item.add(new Label("description", p.description));
        }
    };
    policiesGroup.add(policiesList);
    if (callback != null) {
        policiesGroup.add(callback);
        policiesGroup.setOutputMarkupId(true);
    }
    add(policiesGroup);
    if (app().settings().getBoolean(Keys.web.allowForking, true)) {
        Fragment fragment = new Fragment("allowForks", "allowForksFragment", this);
        fragment.add(new BooleanOption("allowForks", getString("gb.allowForks"), getString("gb.allowForksDescription"), new PropertyModel<Boolean>(repository, "allowForks")));
        add(fragment);
    } else {
        add(new Label("allowForks").setVisible(false));
    }
    setOutputMarkupId(true);
}
Also used : ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) Fragment(org.apache.wicket.markup.html.panel.Fragment) ListView(org.apache.wicket.markup.html.list.ListView) Model(org.apache.wicket.model.Model) RepositoryModel(com.gitblit.models.RepositoryModel) PropertyModel(org.apache.wicket.model.PropertyModel) AccessRestrictionType(com.gitblit.Constants.AccessRestrictionType) AuthorizationControl(com.gitblit.Constants.AuthorizationControl) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 3 with AccessRestrictionType

use of com.gitblit.Constants.AccessRestrictionType in project gitblit by gitblit.

the class EditRepositoryDialog method initialize.

private void initialize(int protocolVersion, RepositoryModel anRepository) {
    nameField = new JTextField(anRepository.name == null ? "" : anRepository.name, 35);
    descriptionField = new JTextField(anRepository.description == null ? "" : anRepository.description, 35);
    JTextField originField = new JTextField(anRepository.origin == null ? "" : anRepository.origin, 40);
    originField.setEditable(false);
    if (ArrayUtils.isEmpty(anRepository.availableRefs)) {
        headRefField = new JComboBox();
        headRefField.setEnabled(false);
    } else {
        headRefField = new JComboBox(anRepository.availableRefs.toArray());
        headRefField.setSelectedItem(anRepository.HEAD);
    }
    Integer[] gcPeriods = { 1, 2, 3, 4, 5, 7, 10, 14 };
    gcPeriod = new JComboBox(gcPeriods);
    gcPeriod.setSelectedItem(anRepository.gcPeriod);
    gcThreshold = new JTextField(8);
    gcThreshold.setText(anRepository.gcThreshold);
    ownersPalette = new JPalette<String>(true);
    acceptNewTickets = new JCheckBox(Translation.get("gb.acceptsNewTicketsDescription"), anRepository.acceptNewTickets);
    acceptNewPatchsets = new JCheckBox(Translation.get("gb.acceptsNewPatchsetsDescription"), anRepository.acceptNewPatchsets);
    requireApproval = new JCheckBox(Translation.get("gb.requireApprovalDescription"), anRepository.requireApproval);
    if (ArrayUtils.isEmpty(anRepository.availableRefs)) {
        mergeToField = new JComboBox();
        mergeToField.setEnabled(false);
    } else {
        mergeToField = new JComboBox(anRepository.availableRefs.toArray());
        mergeToField.setSelectedItem(anRepository.mergeTo);
    }
    useIncrementalPushTags = new JCheckBox(Translation.get("gb.useIncrementalPushTagsDescription"), anRepository.useIncrementalPushTags);
    showRemoteBranches = new JCheckBox(Translation.get("gb.showRemoteBranchesDescription"), anRepository.showRemoteBranches);
    skipSizeCalculation = new JCheckBox(Translation.get("gb.skipSizeCalculationDescription"), anRepository.skipSizeCalculation);
    skipSummaryMetrics = new JCheckBox(Translation.get("gb.skipSummaryMetricsDescription"), anRepository.skipSummaryMetrics);
    isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen);
    maxActivityCommits = new JComboBox(new Integer[] { -1, 0, 25, 50, 75, 100, 150, 250, 500 });
    maxActivityCommits.setSelectedItem(anRepository.maxActivityCommits);
    mailingListsField = new JTextField(ArrayUtils.isEmpty(anRepository.mailingLists) ? "" : StringUtils.flattenStrings(anRepository.mailingLists, " "), 50);
    accessRestriction = new JComboBox(AccessRestrictionType.values());
    accessRestriction.setRenderer(new AccessRestrictionRenderer());
    accessRestriction.setSelectedItem(anRepository.accessRestriction);
    accessRestriction.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                AccessRestrictionType art = (AccessRestrictionType) accessRestriction.getSelectedItem();
                EditRepositoryDialog.this.setupAccessPermissions(art);
            }
        }
    });
    boolean authenticated = anRepository.authorizationControl != null && AuthorizationControl.AUTHENTICATED.equals(anRepository.authorizationControl);
    allowAuthenticated = new JRadioButton(Translation.get("gb.allowAuthenticatedDescription"));
    allowAuthenticated.setSelected(authenticated);
    allowAuthenticated.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                usersPalette.setEnabled(false);
                teamsPalette.setEnabled(false);
            }
        }
    });
    allowNamed = new JRadioButton(Translation.get("gb.allowNamedDescription"));
    allowNamed.setSelected(!authenticated);
    allowNamed.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                usersPalette.setEnabled(true);
                teamsPalette.setEnabled(true);
            }
        }
    });
    ButtonGroup group = new ButtonGroup();
    group.add(allowAuthenticated);
    group.add(allowNamed);
    JPanel authorizationPanel = new JPanel(new GridLayout(0, 1));
    authorizationPanel.add(allowAuthenticated);
    authorizationPanel.add(allowNamed);
    allowForks = new JCheckBox(Translation.get("gb.allowForksDescription"), anRepository.allowForks);
    verifyCommitter = new JCheckBox(Translation.get("gb.verifyCommitterDescription"), anRepository.verifyCommitter);
    // federation strategies - remove ORIGIN choice if this repository has
    // no origin.
    List<FederationStrategy> federationStrategies = new ArrayList<FederationStrategy>(Arrays.asList(FederationStrategy.values()));
    if (StringUtils.isEmpty(anRepository.origin)) {
        federationStrategies.remove(FederationStrategy.FEDERATE_ORIGIN);
    }
    federationStrategy = new JComboBox(federationStrategies.toArray());
    federationStrategy.setRenderer(new FederationStrategyRenderer());
    federationStrategy.setSelectedItem(anRepository.federationStrategy);
    JPanel fieldsPanel = new JPanel(new GridLayout(0, 1));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.name"), nameField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.description"), descriptionField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.origin"), originField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.headRef"), headRefField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.gcPeriod"), gcPeriod));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.gcThreshold"), gcThreshold));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.acceptsNewTickets"), acceptNewTickets));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.acceptsNewPatchsets"), acceptNewPatchsets));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.requireApproval"), requireApproval));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.mergeTo"), mergeToField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.enableIncrementalPushTags"), useIncrementalPushTags));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.showRemoteBranches"), showRemoteBranches));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"), skipSizeCalculation));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSummaryMetrics"), skipSummaryMetrics));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.maxActivityCommits"), maxActivityCommits));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.mailingLists"), mailingListsField));
    JPanel clonePushPanel = new JPanel(new GridLayout(0, 1));
    clonePushPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));
    clonePushPanel.add(newFieldPanel(Translation.get("gb.allowForks"), allowForks));
    clonePushPanel.add(newFieldPanel(Translation.get("gb.verifyCommitter"), verifyCommitter));
    usersPalette = new RegistrantPermissionsPanel(RegistrantType.USER);
    JPanel northFieldsPanel = new JPanel(new BorderLayout(0, 5));
    northFieldsPanel.add(newFieldPanel(Translation.get("gb.owners"), ownersPalette), BorderLayout.NORTH);
    northFieldsPanel.add(newFieldPanel(Translation.get("gb.accessRestriction"), accessRestriction), BorderLayout.CENTER);
    JPanel northAccessPanel = new JPanel(new BorderLayout(5, 5));
    northAccessPanel.add(northFieldsPanel, BorderLayout.NORTH);
    northAccessPanel.add(newFieldPanel(Translation.get("gb.authorizationControl"), authorizationPanel), BorderLayout.CENTER);
    northAccessPanel.add(clonePushPanel, BorderLayout.SOUTH);
    JPanel accessPanel = new JPanel(new BorderLayout(5, 5));
    accessPanel.add(northAccessPanel, BorderLayout.NORTH);
    accessPanel.add(newFieldPanel(Translation.get("gb.userPermissions"), usersPalette), BorderLayout.CENTER);
    teamsPalette = new RegistrantPermissionsPanel(RegistrantType.TEAM);
    JPanel teamsPanel = new JPanel(new BorderLayout(5, 5));
    teamsPanel.add(newFieldPanel(Translation.get("gb.teamPermissions"), teamsPalette), BorderLayout.CENTER);
    setsPalette = new JPalette<String>();
    JPanel federationPanel = new JPanel(new BorderLayout(5, 5));
    federationPanel.add(newFieldPanel(Translation.get("gb.federationStrategy"), federationStrategy), BorderLayout.NORTH);
    federationPanel.add(newFieldPanel(Translation.get("gb.federationSets"), setsPalette), BorderLayout.CENTER);
    indexedBranchesPalette = new JPalette<String>();
    JPanel indexedBranchesPanel = new JPanel(new BorderLayout(5, 5));
    indexedBranchesPanel.add(newFieldPanel(Translation.get("gb.indexedBranches"), indexedBranchesPalette), BorderLayout.CENTER);
    preReceivePalette = new JPalette<String>(true);
    preReceiveInherited = new JLabel();
    JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));
    preReceivePanel.add(preReceivePalette, BorderLayout.CENTER);
    preReceivePanel.add(preReceiveInherited, BorderLayout.WEST);
    postReceivePalette = new JPalette<String>(true);
    postReceiveInherited = new JLabel();
    JPanel postReceivePanel = new JPanel(new BorderLayout(5, 5));
    postReceivePanel.add(postReceivePalette, BorderLayout.CENTER);
    postReceivePanel.add(postReceiveInherited, BorderLayout.WEST);
    customFieldsPanel = new JPanel();
    customFieldsPanel.setLayout(new BoxLayout(customFieldsPanel, BoxLayout.Y_AXIS));
    JScrollPane customFieldsScrollPane = new JScrollPane(customFieldsPanel);
    customFieldsScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    customFieldsScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP);
    panel.addTab(Translation.get("gb.general"), fieldsPanel);
    panel.addTab(Translation.get("gb.accessRestriction"), accessPanel);
    if (protocolVersion >= 2) {
        panel.addTab(Translation.get("gb.teams"), teamsPanel);
    }
    panel.addTab(Translation.get("gb.federation"), federationPanel);
    if (protocolVersion >= 3) {
        panel.addTab(Translation.get("gb.indexedBranches"), indexedBranchesPanel);
    }
    panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel);
    panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel);
    panel.addTab(Translation.get("gb.customFields"), customFieldsScrollPane);
    setupAccessPermissions(anRepository.accessRestriction);
    JButton createButton = new JButton(Translation.get("gb.save"));
    createButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (validateFields()) {
                canceled = false;
                setVisible(false);
            }
        }
    });
    JButton cancelButton = new JButton(Translation.get("gb.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            canceled = true;
            setVisible(false);
        }
    });
    JPanel controls = new JPanel();
    controls.add(cancelButton);
    controls.add(createButton);
    final Insets _insets = new Insets(5, 5, 5, 5);
    JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    centerPanel.add(panel, BorderLayout.CENTER);
    centerPanel.add(controls, BorderLayout.SOUTH);
    getContentPane().setLayout(new BorderLayout(5, 5));
    getContentPane().add(centerPanel, BorderLayout.CENTER);
    pack();
    nameField.requestFocus();
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JTabbedPane(javax.swing.JTabbedPane) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) AccessRestrictionType(com.gitblit.Constants.AccessRestrictionType) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) FederationStrategy(com.gitblit.Constants.FederationStrategy) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ItemListener(java.awt.event.ItemListener)

Example 4 with AccessRestrictionType

use of com.gitblit.Constants.AccessRestrictionType in project gitblit by gitblit.

the class PermissionsTest method testAdmin.

/**
	 * Admin access rights/permissions
	 */
@Test
public void testAdmin() throws Exception {
    UserModel user = new UserModel("admin");
    user.canAdmin = true;
    for (AccessRestrictionType ar : AccessRestrictionType.values()) {
        RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
        repository.authorizationControl = AuthorizationControl.NAMED;
        repository.accessRestriction = ar;
        assertTrue("admin CAN NOT view!", user.canView(repository));
        assertTrue("admin CAN NOT clone!", user.canClone(repository));
        assertTrue("admin CAN NOT push!", user.canPush(repository));
        assertTrue("admin CAN NOT create ref!", user.canCreateRef(repository));
        assertTrue("admin CAN NOT delete ref!", user.canDeleteRef(repository));
        assertTrue("admin CAN NOT rewind ref!", user.canRewindRef(repository));
        assertEquals("admin has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
        assertTrue("admin CAN NOT fork!", user.canFork(repository));
        assertTrue("admin CAN NOT delete!", user.canDelete(repository));
        assertTrue("admin CAN NOT edit!", user.canEdit(repository));
    }
}
Also used : UserModel(com.gitblit.models.UserModel) AccessRestrictionType(com.gitblit.Constants.AccessRestrictionType) RepositoryModel(com.gitblit.models.RepositoryModel) Date(java.util.Date) Test(org.junit.Test)

Aggregations

AccessRestrictionType (com.gitblit.Constants.AccessRestrictionType)4 RepositoryModel (com.gitblit.models.RepositoryModel)3 ArrayList (java.util.ArrayList)3 AuthorizationControl (com.gitblit.Constants.AuthorizationControl)2 FederationStrategy (com.gitblit.Constants.FederationStrategy)1 GitBlitException (com.gitblit.GitBlitException)1 UserModel (com.gitblit.models.UserModel)1 AccessPolicyPanel (com.gitblit.wicket.panels.AccessPolicyPanel)1 BooleanChoiceOption (com.gitblit.wicket.panels.BooleanChoiceOption)1 BooleanOption (com.gitblit.wicket.panels.BooleanOption)1 RepositoryNamePanel (com.gitblit.wicket.panels.RepositoryNamePanel)1 BorderLayout (java.awt.BorderLayout)1 GridLayout (java.awt.GridLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 File (java.io.File)1 Date (java.util.Date)1