public void OAuth2LeggedDocumentsTest() { Tracing.TraceMsg("Entering OAuth2LeggedDocumentsTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.oAuthConsumerKey, this.oAuthConsumerSecret, this.oAuthUser, this.oAuthDomain); DocumentsRequest dr = new DocumentsRequest(rs); Feed<Document> f = dr.GetDocuments(); // modify one foreach (Document d in f.Entries) { string s = d.AtomEntry.EditUri.ToString(); d.AtomEntry.EditUri = new AtomUri(s.Replace("@", "%40")); dr.Update(d); AclQuery q = new AclQuery(); q.Uri = d.AccessControlList; Feed<Google.AccessControl.Acl> facl = dr.Get<Google.AccessControl.Acl>(q); foreach (Google.AccessControl.Acl a in facl.Entries) { s = a.AclEntry.EditUri.ToString(); a.AclEntry.EditUri = new AtomUri(s.Replace("@", "%40")); dr.Update(a); } } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>Tests the ACL extensions</summary> ////////////////////////////////////////////////////////////////////// [Test] public void CalendarACLTest() { Tracing.TraceMsg("Entering CalendarACLTest"); AclQuery query = new AclQuery(); CalendarService service = new CalendarService(this.ApplicationName); int iCount; if (this.defaultCalendarUri != null) { if (this.userName != null) { service.Credentials = new GDataCredentials(this.userName, this.passWord); } service.RequestFactory = this.factory; query.Uri = new Uri(this.aclFeedUri); AclFeed aclFeed = service.Query(query); AclEntry newEntry = null; foreach (AclEntry e in aclFeed.Entries ) { if (e.Scope.Value.StartsWith(this.userName) == false) { e.Delete(); } } aclFeed = service.Query(query); iCount = aclFeed.Entries.Count; if (aclFeed != null) { // create an entry AclEntry entry = new AclEntry(); entry.Role = AclRole.ACL_CALENDAR_FREEBUSY; AclScope scope = new AclScope(); scope.Type = AclScope.SCOPE_USER; scope.Value = "*****@*****.**"; entry.Scope = scope; newEntry = (AclEntry) aclFeed.Insert(entry); Assert.AreEqual(newEntry.Role.Value, entry.Role.Value); Assert.AreEqual(newEntry.Scope.Type, entry.Scope.Type); Assert.AreEqual(newEntry.Scope.Value, entry.Scope.Value); } Tracing.TraceMsg("CalendarACLTest: done insering Acl:entry"); iCount++; aclFeed = (AclFeed) service.Query(query); Tracing.TraceMsg("CalendarACLTest: done query after: Acl:entry"); // update that entry if (newEntry != null) { newEntry.Role = AclRole.ACL_CALENDAR_READ; newEntry = (AclEntry) newEntry.Update(); Assert.AreEqual(AclRole.ACL_CALENDAR_READ.Value, newEntry.Role.Value); } Tracing.TraceMsg("CalendarACLTest: done updating Acl:entry"); newEntry.Delete(); iCount--; Tracing.TraceMsg("CalendarACLTest: done deleting Acl:entry"); aclFeed = (AclFeed) service.Query(query); Assert.AreEqual(iCount, aclFeed.Entries.Count, "Feed should have one more entry, it has: " + aclFeed.Entries.Count); service.Credentials = null; } }
/// <summary> /// overloaded to create typed version of Query /// </summary> /// <param name="feedQuery"></param> /// <returns>EventFeed</returns> public AclFeed Query(AclQuery feedQuery) { return base.Query(feedQuery) as AclFeed; }
protected override void ProcessRecord() { var _domain = dgcGoogleCalendarService.GetDomain(service.CalendarService); var _query = new CalendarQuery(); _query.Uri = new Uri(selfUri); try { var _entry = service.CalendarService.Query(_query); var _links = _entry.Entries[0].Links; if (_links == null) { throw new Exception("AclFeed new null"); } var _linkSelection = from _selection in _links where _selection.Rel.ToString() == "http://schemas.google.com/acl/2007#accessControlList" select _selection; foreach (var _Link in _linkSelection) { var _aclQuery = new AclQuery(_Link.HRef.ToString()); var _Feed = service.CalendarService.Query(_aclQuery); var _feedSelection = from AclEntry _selection in _Feed.Entries where _selection.Scope.Value.ToString() == id select _selection; foreach (AclEntry _aclEntry in _feedSelection) { _aclEntry.Delete(); WriteObject(id); } } } catch (Exception _exception) { WriteObject(_exception); } }