本文整理汇总了Java中org.eclipse.jgit.internal.storage.dfs.InMemoryRepository类的典型用法代码示例。如果您正苦于以下问题:Java InMemoryRepository类的具体用法?Java InMemoryRepository怎么用?Java InMemoryRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InMemoryRepository类属于org.eclipse.jgit.internal.storage.dfs包,在下文中一共展示了InMemoryRepository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: fetchExternalIdsBranch
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void fetchExternalIdsBranch() throws Exception {
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers, user);
// refs/meta/external-ids is only visible to users with the 'Access Database' capability
try {
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
fail("expected TransportException");
} catch (TransportException e) {
assertThat(e.getMessage())
.isEqualTo(
"Remote does not have " + RefNames.REFS_EXTERNAL_IDS + " available for fetch.");
}
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
// re-clone to get new request context, otherwise the old global capabilities are still cached
// in the IdentifiedUser object
allUsersRepo = cloneProject(allUsers, user);
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:ExternalIdIT.java
示例2: setUp
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
TestKey key1 = validKeyWithoutExpiration();
TestKey key3 = expiredKey();
repo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
store = new PublicKeyStore(repo);
store.add(key1.getPublicKeyRing());
store.add(key3.getPublicKeyRing());
PersonIdent ident = new PersonIdent("A U Thor", "[email protected]");
CommitBuilder cb = new CommitBuilder();
cb.setAuthor(ident);
cb.setCommitter(ident);
assertEquals(RefUpdate.Result.NEW, store.save(cb));
signedPushConfig = new SignedPushConfig();
signedPushConfig.setCertNonceSeed("sekret");
signedPushConfig.setCertNonceSlopLimit(60 * 24);
checker = newChecker(true);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:PushCertificateCheckerTest.java
示例3: createEditWithoutPushPatchSetPermission
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void createEditWithoutPushPatchSetPermission() throws Exception {
// Create new project with clean permissions
Project.NameKey p = createProject("addPatchSetEdit");
// Clone repository as user
TestRepository<InMemoryRepository> userTestRepo = cloneProject(p, user);
// Block default permission
block(p, "refs/for/*", Permission.ADD_PATCH_SET, REGISTERED_USERS);
// Create change as user
PushOneCommit push = pushFactory.create(db, user.getIdent(), userTestRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
r1.assertOkStatus();
// Try to create edit as admin
exception.expect(AuthException.class);
createEmptyEditFor(r1.getChangeId());
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:ChangeEditIT.java
示例4: pushToUserBranchForReview
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void pushToUserBranchForReview() throws Exception {
String userRefName = RefNames.refsUsers(admin.id);
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, userRefName + ":userRef");
allUsersRepo.reset("userRef");
PushOneCommit push = pushFactory.create(db, admin.getIdent(), allUsersRepo);
PushOneCommit.Result r = push.to(MagicBranch.NEW_CHANGE + userRefName);
r.assertOkStatus();
accountIndexedCounter.assertNoReindex();
assertThat(r.getChange().change().getDest().get()).isEqualTo(userRefName);
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).current().submit();
accountIndexedCounter.assertReindexOf(admin);
push = pushFactory.create(db, admin.getIdent(), allUsersRepo);
r = push.to(MagicBranch.NEW_CHANGE + RefNames.REFS_USERS_SELF);
r.assertOkStatus();
accountIndexedCounter.assertNoReindex();
assertThat(r.getChange().change().getDest().get()).isEqualTo(userRefName);
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).current().submit();
accountIndexedCounter.assertReindexOf(admin);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:AccountIT.java
示例5: pushAccountConfigToUserBranchIsRejectedIfPreferredEmailIsInvalid
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void pushAccountConfigToUserBranchIsRejectedIfPreferredEmailIsInvalid() throws Exception {
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, RefNames.refsUsers(admin.id) + ":userRef");
allUsersRepo.reset("userRef");
String noEmail = "no.email";
Config ac = getAccountConfig(allUsersRepo);
ac.setString(AccountConfig.ACCOUNT, null, AccountConfig.KEY_PREFERRED_EMAIL, noEmail);
PushOneCommit.Result r =
pushFactory
.create(
db,
admin.getIdent(),
allUsersRepo,
"Update account config",
AccountConfig.ACCOUNT_CONFIG,
ac.toText())
.to(RefNames.REFS_USERS_SELF);
r.assertErrorStatus("invalid account configuration");
r.assertMessage(
String.format("invalid preferred email '%s' for account '%s'", noEmail, admin.id));
accountIndexedCounter.assertNoReindex();
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:AccountIT.java
示例6: pushAccountConfigToUserBranchIsRejectedIfOwnAccountIsDeactivated
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void pushAccountConfigToUserBranchIsRejectedIfOwnAccountIsDeactivated() throws Exception {
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, RefNames.refsUsers(admin.id) + ":userRef");
allUsersRepo.reset("userRef");
Config ac = getAccountConfig(allUsersRepo);
ac.setBoolean(AccountConfig.ACCOUNT, null, AccountConfig.KEY_ACTIVE, false);
PushOneCommit.Result r =
pushFactory
.create(
db,
admin.getIdent(),
allUsersRepo,
"Update account config",
AccountConfig.ACCOUNT_CONFIG,
ac.toText())
.to(RefNames.REFS_USERS_SELF);
r.assertErrorStatus("invalid account configuration");
r.assertMessage("cannot deactivate own account");
accountIndexedCounter.assertNoReindex();
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:AccountIT.java
示例7: cannotCreateUserBranch
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
@Sandboxed
public void cannotCreateUserBranch() throws Exception {
grant(allUsers, RefNames.REFS_USERS + "*", Permission.CREATE);
grant(allUsers, RefNames.REFS_USERS + "*", Permission.PUSH);
String userRef = RefNames.refsUsers(new Account.Id(seq.nextAccountId()));
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), allUsersRepo).to(userRef);
r.assertErrorStatus();
assertThat(r.getMessage()).contains("Not allowed to create user branch.");
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(userRef)).isNull();
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:AccountIT.java
示例8: cannotCreateNonUserBranchUnderRefsUsersWithAccessDatabaseCapability
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
@Sandboxed
public void cannotCreateNonUserBranchUnderRefsUsersWithAccessDatabaseCapability()
throws Exception {
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
grant(allUsers, RefNames.REFS_USERS + "*", Permission.CREATE);
grant(allUsers, RefNames.REFS_USERS + "*", Permission.PUSH);
String userRef = RefNames.REFS_USERS + "foo";
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), allUsersRepo).to(userRef);
r.assertErrorStatus();
assertThat(r.getMessage()).contains("Not allowed to create non-user branch under refs/users/.");
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(userRef)).isNull();
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:AccountIT.java
示例9: createDefaultUserBranch
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
@Sandboxed
public void createDefaultUserBranch() throws Exception {
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(RefNames.REFS_USERS_DEFAULT)).isNull();
}
grant(allUsers, RefNames.REFS_USERS_DEFAULT, Permission.CREATE);
grant(allUsers, RefNames.REFS_USERS_DEFAULT, Permission.PUSH);
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
pushFactory
.create(db, admin.getIdent(), allUsersRepo)
.to(RefNames.REFS_USERS_DEFAULT)
.assertOkStatus();
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(RefNames.REFS_USERS_DEFAULT)).isNotNull();
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:AccountIT.java
示例10: cannotDeleteUserBranch
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
@Sandboxed
public void cannotDeleteUserBranch() throws Exception {
grant(
allUsers,
RefNames.REFS_USERS + "${" + RefPattern.USERID_SHARDED + "}",
Permission.DELETE,
true,
REGISTERED_USERS);
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
String userRef = RefNames.refsUsers(admin.id);
PushResult r = deleteRef(allUsersRepo, userRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(userRef);
assertThat(refUpdate.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
assertThat(refUpdate.getMessage()).contains("Not allowed to delete user branch.");
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(userRef)).isNotNull();
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:AccountIT.java
示例11: deleteUserBranchWithAccessDatabaseCapability
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
@Sandboxed
public void deleteUserBranchWithAccessDatabaseCapability() throws Exception {
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
grant(
allUsers,
RefNames.REFS_USERS + "${" + RefPattern.USERID_SHARDED + "}",
Permission.DELETE,
true,
REGISTERED_USERS);
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
String userRef = RefNames.refsUsers(admin.id);
PushResult r = deleteRef(allUsersRepo, userRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(userRef);
assertThat(refUpdate.getStatus()).isEqualTo(RemoteRefUpdate.Status.OK);
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(userRef)).isNull();
}
assertThat(accountCache.getOrNull(admin.id)).isNull();
assertThat(accountQueryProvider.get().byDefault(admin.id.toString())).isEmpty();
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:AccountIT.java
示例12: cleanUp
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@After
public void cleanUp() throws Exception {
gApi.accounts().id(admin.getId().toString()).setDiffPreferences(DiffPreferencesInfo.defaults());
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
try {
fetch(allUsersRepo, RefNames.REFS_USERS_DEFAULT + ":defaults");
} catch (TransportException e) {
if (e.getMessage()
.equals(
"Remote does not have " + RefNames.REFS_USERS_DEFAULT + " available for fetch.")) {
return;
}
throw e;
}
allUsersRepo.reset("defaults");
PushOneCommit push =
pushFactory.create(
db,
admin.getIdent(),
allUsersRepo,
"Delete default preferences",
VersionedAccountPreferences.PREFERENCES,
"");
push.rm(RefNames.REFS_USERS_DEFAULT).assertOkStatus();
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:DiffPreferencesIT.java
示例13: pushGroupsAccessSectionChangeToAllUsersFails
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void pushGroupsAccessSectionChangeToAllUsersFails() throws Exception {
TestRepository<InMemoryRepository> repo = cloneProject(allUsers, RefNames.REFS_CONFIG);
String config =
gApi.projects()
.name(allUsers.get())
.branch(RefNames.REFS_CONFIG)
.file(ProjectConfig.PROJECT_CONFIG)
.asString();
Config cfg = new Config();
cfg.fromText(config);
cfg.setString("access", RefNames.REFS_GROUPS + "foo", "push", "group Registered Users");
config = cfg.toText();
PushOneCommit.Result r =
pushFactory
.create(db, admin.getIdent(), repo, "Subject", ProjectConfig.PROJECT_CONFIG, config)
.to(RefNames.REFS_CONFIG);
r.assertErrorStatus("invalid project configuration");
r.assertMessage("permissions on refs/groups/ are managed by gerrit and cannot be modified");
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:GroupsIT.java
示例14: pushCustomInheritanceForAllUsersFails
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void pushCustomInheritanceForAllUsersFails() throws Exception {
TestRepository<InMemoryRepository> repo = cloneProject(allUsers, RefNames.REFS_CONFIG);
String config =
gApi.projects()
.name(allUsers.get())
.branch(RefNames.REFS_CONFIG)
.file("project.config")
.asString();
Config cfg = new Config();
cfg.fromText(config);
cfg.setString("access", null, "inheritFrom", project.get());
config = cfg.toText();
PushOneCommit.Result r =
pushFactory
.create(db, admin.getIdent(), repo, "Subject", "project.config", config)
.to(RefNames.REFS_CONFIG);
r.assertErrorStatus("invalid project configuration");
r.assertMessage("All-Users must inherit from All-Projects");
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:GroupsIT.java
示例15: cannotCreateGroupBranch
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
@Sandboxed
public void cannotCreateGroupBranch() throws Exception {
grant(allUsers, RefNames.REFS_GROUPS + "*", Permission.CREATE);
grant(allUsers, RefNames.REFS_GROUPS + "*", Permission.PUSH);
String groupRef = RefNames.refsGroups(new AccountGroup.UUID(name("foo")));
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), allUsersRepo).to(groupRef);
r.assertErrorStatus();
assertThat(r.getMessage()).contains("Not allowed to create group branch.");
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(groupRef)).isNull();
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:GroupsIT.java
示例16: cannotDeleteGroupBranch
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
@Sandboxed
public void cannotDeleteGroupBranch() throws Exception {
assume().that(groupsInNoteDb()).isTrue();
grant(allUsers, RefNames.REFS_GROUPS + "*", Permission.DELETE, true, REGISTERED_USERS);
InternalGroup adminGroup =
groupCache.get(new AccountGroup.NameKey("Administrators")).orElse(null);
assertThat(adminGroup).isNotNull();
String groupRef = RefNames.refsGroups(adminGroup.getGroupUUID());
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
PushResult r = deleteRef(allUsersRepo, groupRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(groupRef);
assertThat(refUpdate.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
assertThat(refUpdate.getMessage()).contains("Not allowed to delete group branch.");
try (Repository repo = repoManager.openRepository(allUsers)) {
assertThat(repo.exactRef(groupRef)).isNotNull();
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:GroupsIT.java
示例17: accessPrivate
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void accessPrivate() throws Exception {
TestRepository<InMemoryRepository> userRepo = cloneProject(project, user);
PushOneCommit.Result result =
pushFactory.create(db, user.getIdent(), userRepo).to("refs/for/master");
setApiUser(user);
gApi.changes().id(result.getChangeId()).setPrivate(true, null);
// Owner can always access its private changes.
assertThat(gApi.changes().id(result.getChangeId()).get().isPrivate).isTrue();
// Add admin as a reviewer.
gApi.changes().id(result.getChangeId()).addReviewer(admin.getId().toString());
// This change should be visible for admin as a reviewer.
setApiUser(admin);
assertThat(gApi.changes().id(result.getChangeId()).get().isPrivate).isTrue();
// Remove admin from reviewers.
gApi.changes().id(result.getChangeId()).reviewer(admin.getId().toString()).remove();
// This change should not be visible for admin anymore.
exception.expect(ResourceNotFoundException.class);
exception.expectMessage("Not found: " + result.getChangeId());
gApi.changes().id(result.getChangeId());
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:ChangeIT.java
示例18: ownerCannotMarkPrivateAfterMerging
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void ownerCannotMarkPrivateAfterMerging() throws Exception {
TestRepository<InMemoryRepository> userRepo = cloneProject(project, user);
PushOneCommit.Result result =
pushFactory.create(db, user.getIdent(), userRepo).to("refs/for/master");
String changeId = result.getChangeId();
assertThat(gApi.changes().id(changeId).get().isPrivate).isNull();
merge(result);
setApiUser(user);
exception.expect(AuthException.class);
exception.expectMessage("not allowed to mark private");
gApi.changes().id(changeId).setPrivate(true, null);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:ChangeIT.java
示例19: ownerCanUnmarkPrivateAfterMerging
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void ownerCanUnmarkPrivateAfterMerging() throws Exception {
TestRepository<InMemoryRepository> userRepo = cloneProject(project, user);
PushOneCommit.Result result =
pushFactory.create(db, user.getIdent(), userRepo).to("refs/for/master");
String changeId = result.getChangeId();
assertThat(gApi.changes().id(changeId).get().isPrivate).isNull();
gApi.changes().id(changeId).addReviewer(admin.getId().toString());
gApi.changes().id(changeId).setPrivate(true, null);
assertThat(gApi.changes().id(changeId).get().isPrivate).isTrue();
merge(result);
setApiUser(user);
gApi.changes().id(changeId).setPrivate(false, null);
assertThat(gApi.changes().id(changeId).get().isPrivate).isNull();
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:ChangeIT.java
示例20: createNewPatchSetWithoutPermission
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; //导入依赖的package包/类
@Test
public void createNewPatchSetWithoutPermission() throws Exception {
// Create new project with clean permissions
Project.NameKey p = createProject("addPatchSet1");
// Clone separate repositories of the same project as admin and as user
TestRepository<InMemoryRepository> adminTestRepo = cloneProject(p, admin);
TestRepository<InMemoryRepository> userTestRepo = cloneProject(p, user);
// Block default permission
block(p, "refs/for/*", Permission.ADD_PATCH_SET, REGISTERED_USERS);
// Create change as admin
PushOneCommit push = pushFactory.create(db, admin.getIdent(), adminTestRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
r1.assertOkStatus();
// Fetch change
GitUtil.fetch(userTestRepo, r1.getPatchSet().getRefName() + ":ps");
userTestRepo.reset("ps");
// Amend change as user
PushOneCommit.Result r2 = amendChange(r1.getChangeId(), "refs/for/master", user, userTestRepo);
r2.assertErrorStatus("cannot add patch set to " + r1.getChange().getId().id + ".");
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:ChangeIT.java
注:本文中的org.eclipse.jgit.internal.storage.dfs.InMemoryRepository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论